X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=96d4fa1086869383e65b85e926b1bec74120b1e2;hb=defb9fb4e9786443daac7e17d9d5dbe5d6f15098;hp=3ebb1396f97df7130e6cbc7cd5c7937023921aa0;hpb=350f8aa72dd8640a455e2546ca7ebab67d457863;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index 3ebb1396f97..96d4fa10868 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -24,8 +24,10 @@
  • Calling Conventions
  • Global Variables
  • Functions
  • +
  • Aliases
  • Parameter Attributes
  • Module-Level Inline Assembly
  • +
  • Data Layout
  • Type System @@ -42,7 +44,7 @@
  • Pointer Type
  • Structure Type
  • Packed Structure Type
  • -
  • Packed Type
  • +
  • Vector Type
  • Opaque Type
  • @@ -89,12 +91,12 @@
  • Bitwise Binary Operations
      -
    1. 'and' Instruction
    2. -
    3. 'or' Instruction
    4. -
    5. 'xor' Instruction
    6. 'shl' Instruction
    7. 'lshr' Instruction
    8. 'ashr' Instruction
    9. +
    10. 'and' Instruction
    11. +
    12. 'or' Instruction
    13. +
    14. 'xor' Instruction
  • Vector Operations @@ -145,48 +147,56 @@
    1. Variable Argument Handling Intrinsics
        -
      1. 'llvm.va_start' Intrinsic
      2. -
      3. 'llvm.va_end' Intrinsic
      4. -
      5. 'llvm.va_copy' Intrinsic
      6. +
      7. 'llvm.va_start' Intrinsic
      8. +
      9. 'llvm.va_end' Intrinsic
      10. +
      11. 'llvm.va_copy' Intrinsic
    2. Accurate Garbage Collection Intrinsics
        -
      1. 'llvm.gcroot' Intrinsic
      2. -
      3. 'llvm.gcread' Intrinsic
      4. -
      5. 'llvm.gcwrite' Intrinsic
      6. +
      7. 'llvm.gcroot' Intrinsic
      8. +
      9. 'llvm.gcread' Intrinsic
      10. +
      11. 'llvm.gcwrite' Intrinsic
    3. Code Generator Intrinsics
        -
      1. 'llvm.returnaddress' Intrinsic
      2. -
      3. 'llvm.frameaddress' Intrinsic
      4. -
      5. 'llvm.stacksave' Intrinsic
      6. -
      7. 'llvm.stackrestore' Intrinsic
      8. -
      9. 'llvm.prefetch' Intrinsic
      10. -
      11. 'llvm.pcmarker' Intrinsic
      12. -
      13. llvm.readcyclecounter' Intrinsic
      14. +
      15. 'llvm.returnaddress' Intrinsic
      16. +
      17. 'llvm.frameaddress' Intrinsic
      18. +
      19. 'llvm.stacksave' Intrinsic
      20. +
      21. 'llvm.stackrestore' Intrinsic
      22. +
      23. 'llvm.prefetch' Intrinsic
      24. +
      25. 'llvm.pcmarker' Intrinsic
      26. +
      27. llvm.readcyclecounter' Intrinsic
    4. Standard C Library Intrinsics
        -
      1. 'llvm.memcpy.*' Intrinsic
      2. -
      3. 'llvm.memmove.*' Intrinsic
      4. -
      5. 'llvm.memset.*' Intrinsic
      6. -
      7. 'llvm.isunordered.*' Intrinsic
      8. -
      9. 'llvm.sqrt.*' Intrinsic
      10. -
      11. 'llvm.powi.*' Intrinsic
      12. +
      13. 'llvm.memcpy.*' Intrinsic
      14. +
      15. 'llvm.memmove.*' Intrinsic
      16. +
      17. 'llvm.memset.*' Intrinsic
      18. +
      19. 'llvm.sqrt.*' Intrinsic
      20. +
      21. 'llvm.powi.*' Intrinsic
    5. Bit Manipulation Intrinsics
        -
      1. 'llvm.bswap.*' Intrinsics
      2. +
      3. 'llvm.bswap.*' Intrinsics
      4. 'llvm.ctpop.*' Intrinsic
      5. 'llvm.ctlz.*' Intrinsic
      6. 'llvm.cttz.*' Intrinsic
      7. +
      8. 'llvm.part.select.*' Intrinsic
      9. +
      10. 'llvm.part.set.*' Intrinsic
    6. Debugger intrinsics
    7. +
    8. Exception Handling intrinsics
    9. +
    10. General intrinsics
    11. +
        +
      1. 'llvm.var.annotation' + Intrinsic
      2. +
      +
  • @@ -248,9 +258,11 @@ LLVM assembly language. There is a difference between what the parser accepts and what is considered 'well formed'. For example, the following instruction is syntactically okay, but not well formed:

    +
    -  %x = add i32 1, %x
    +%x = add i32 1, %x
     
    +

    ...because the definition of %x does not dominate all of its uses. The LLVM infrastructure provides a verification pass that may @@ -259,6 +271,7 @@ automatically run by the parser after parsing input assembly and by the optimizer before it outputs bytecode. The violations pointed out by the verifier pass indicate bugs in transformation passes or input to the parser.

    + @@ -276,7 +289,7 @@ purposes:

    For example, %foo, %DivisionByZero, %a.really.long.identifier. The actual regular expression used is '%[a-zA-Z$._][a-zA-Z$._0-9]*'. Identifiers which require other characters in their names can be surrounded - with quotes. In this way, anything except a " character can be used + with quotes. In this way, anything except a " character can be used in a name.
  • Unnamed values are represented as an unsigned numeric value with a '%' @@ -306,23 +319,29 @@ none of them start with a '%' character.

    The easy way:

    +
    -  %result = mul i32 %X, 8
    +%result = mul i32 %X, 8
     
    +

    After strength reduction:

    +
    -  %result = shl i32 %X, i8 3
    +%result = shl i32 %X, i8 3
     
    +

    And the hard way:

    +
    -  add i32 %X, %X           ; yields {i32}:%0
    -  add i32 %0, %0           ; yields {i32}:%1
    -  %result = add i32 %1, %1
    +add i32 %X, %X           ; yields {i32}:%0
    +add i32 %0, %0           ; yields {i32}:%1
    +%result = add i32 %1, %1
     
    +

    This last way of multiplying %X by 8 illustrates several important lexical features of LLVM:

    @@ -363,27 +382,27 @@ combined together with the LLVM linker, which merges function (and global variable) definitions, resolves forward declarations, and merges symbol table entries. Here is an example of the "hello world" module:

    +
    ; Declare the string constant as a global constant...
    -%.LC0 = internal constant [13 x i8 ] c"hello world\0A\00"          ; [13 x i8 ]*
    +@.LC0 = internal constant [13 x i8] c"hello world\0A\00"          ; [13 x i8]*
     
     ; External declaration of the puts function
    -declare i32 %puts(i8 *)                                            ; i32(i8 *)* 
    -
    -; Global variable / Function body section separator
    -implementation
    +declare i32 @puts(i8 *)                                            ; i32(i8 *)* 
     
     ; Definition of main function
    -define i32 %main() {                                                 ; i32()* 
    +define i32 @main() {                                                 ; i32()* 
             ; Convert [13x i8 ]* to i8  *...
             %cast210 = getelementptr [13 x i8 ]* %.LC0, i64 0, i64 0 ; i8 *
    + href="#i_getelementptr">getelementptr [13 x i8 ]* @.LC0, i64 0, i64 0 ; i8 *
     
             ; Call puts function to write out the string to stdout...
             call i32 %puts(i8 * %cast210)                              ; i32
    + href="#i_call">call i32 @puts(i8 * %cast210)                              ; i32
             ret i32 0
    }
    + href="#i_ret">ret i32 0
    }
    + +

    This example is made up of a global variable named ".LC0", an external declaration of the "puts" @@ -396,13 +415,6 @@ represented by a pointer to a memory location (in this case, a pointer to an array of char, and a pointer to a function), and have one of the following linkage types.

    -

    Due to a limitation in the current LLVM assembly parser (it is limited by -one-token lookahead), modules are split into two pieces by the "implementation" -keyword. Global variable prototypes and definitions must occur before the -keyword, and function definitions must occur after it. Function prototypes may -occur either before or after it. In the future, the implementation keyword may -become a noop, if the parser gets smarter.

    - @@ -425,23 +437,26 @@ All Global Variables and Functions have one of the following types of linkage: an internal global value may cause the internal to be renamed as necessary to avoid collisions. Because the symbol is internal to the module, all references can be updated. This corresponds to the notion of the - 'static' keyword in C, or the idea of "anonymous namespaces" in C++. + 'static' keyword in C.
    linkonce:
    -
    "linkonce" linkage is similar to internal linkage, with - the twist that linking together two modules defining the same - linkonce globals will cause one of the globals to be discarded. This - is typically used to implement inline functions. Unreferenced - linkonce globals are allowed to be discarded. +
    Globals with "linkonce" linkage are merged with other globals of + the same name when linkage occurs. This is typically used to implement + inline functions, templates, or other code which must be generated in each + translation unit that uses it. Unreferenced linkonce globals are + allowed to be discarded.
    weak:
    "weak" linkage is exactly the same as linkonce linkage, except that unreferenced weak globals may not be discarded. This is - used to implement constructs in C such as "i32 X;" at global scope. + used for globals that may be emitted in multiple translation units, but that + are not guaranteed to be emitted into every translation unit that uses them. + One example of this are common globals in C, such as "int X;" at + global scope.
    appending:
    @@ -453,17 +468,19 @@ All Global Variables and Functions have one of the following types of linkage: "sections" with identical names when .o files are linked. +
    extern_weak:
    +
    The semantics of this linkage follow the ELF model: the symbol is weak + until linked, if not linked, the symbol becomes null instead of being an + undefined reference. +
    +
    externally visible:
    If none of the above identifiers are used, the global is externally visible, meaning that it participates in linkage and can be used to resolve external symbol references.
    - -
    extern_weak:
    - -
    "extern_weak" TBD -
    +

    The next two types of linkage are targeted for Microsoft Windows platform @@ -471,6 +488,7 @@ All Global Variables and Functions have one of the following types of linkage: DLLs.

    +
    dllimport:
    "dllimport" linkage causes the compiler to reference a function @@ -490,14 +508,17 @@ All Global Variables and Functions have one of the following types of linkage:
    -

    For example, since the ".LC0" +

    For example, since the ".LC0" variable is defined to be internal, if another module defined a ".LC0" variable and was linked with this one, one of the two would be renamed, preventing a collision. Since "main" and "puts" are external (i.e., lacking any linkage declarations), they are accessible -outside of the current module. It is illegal for a function declaration -to have any linkage type other than "externally visible".

    - +outside of the current module.

    +

    It is illegal for a function declaration +to have any linkage type other than "externally visible", dllimport, +or extern_weak.

    +

    Aliases can have only external, internal and weak +linkages. @@ -523,19 +544,6 @@ the future:

    prototype and implemented declaration of the function (as does normal C). -
    "csretcc" - The C struct return calling convention:
    - -
    This calling convention matches the target C calling conventions, except - that functions with this convention are required to take a pointer as their - first argument, and the return type of the function must be void. This is - used for C functions that return aggregates by-value. In this case, the - function has been transformed to take a pointer to the struct as the first - argument to the function. For targets where the ABI specifies specific - behavior for structure-return calls, the calling convention can be used to - distinguish between struct return functions and other functions that take a - pointer to a struct as the first argument. -
    -
    "fastcc" - The fast calling convention:
    This calling convention attempts to make calls as fast as possible @@ -571,6 +579,47 @@ convention.

    + + + +
    + +

    +All Global Variables and Functions have one of the following visibility styles: +

    + +
    +
    "default" - Default style:
    + +
    On ELF, default visibility means that the declaration is visible to other + modules and, in shared libraries, means that the declared entity may be + overridden. On Darwin, default visibility means that the declaration is + visible to other modules. Default visibility corresponds to "external + linkage" in the language. +
    + +
    "hidden" - Hidden style:
    + +
    Two declarations of an object with hidden visibility refer to the same + object if they are in the same shared object. Usually, hidden visibility + indicates that the symbol will not be placed into the dynamic symbol table, + so no other module (executable or shared library) can reference it + directly. +
    + +
    "protected" - Protected style:
    + +
    On ELF, protected visibility indicates that the symbol will be placed in + the dynamic symbol table, but that references within the defining module will + bind to the local symbol. That is, the symbol cannot be overridden by another + module. +
    +
    + +
    +
    Global Variables @@ -580,10 +629,11 @@ convention.

    Global variables define regions of memory allocated at compilation time instead of run-time. Global variables may optionally be initialized, may have -an explicit section to be placed in, and may -have an optional explicit alignment specified. A -variable may be defined as a global "constant," which indicates that the -contents of the variable will never be modified (enabling better +an explicit section to be placed in, and may have an optional explicit alignment +specified. A variable may be defined as "thread_local", which means that it +will not be shared by threads (each thread will have a separated copy of the +variable). A variable may be defined as a global "constant," which indicates +that the contents of the variable will never be modified (enabling better optimization, allowing the global data to be placed in the read-only section of an executable, etc). Note that variables that need runtime initialization cannot be marked "constant" as there is a store to the variable.

    @@ -612,6 +662,15 @@ to whatever it feels convenient. If an explicit alignment is specified, the global is forced to have at least that much alignment. All alignments must be a power of 2.

    +

    For example, the following defines a global with an initializer, section, + and alignment:

    + +
    +
    +%G = constant float 1.0, section "foo", align 4
    +
    +
    +
    @@ -624,14 +683,18 @@ a power of 2.

    LLVM function definitions consist of the "define" keyord, an optional linkage type, an optional +visibility style, an optional calling convention, a return type, an optional parameter attribute for the return type, a function name, a (possibly empty) argument list (each with optional -parameter attributes), an optional section, an -optional alignment, an opening curly brace, a list of basic blocks, and a -closing curly brace. LLVM function declarations -consist of the "declare" keyword, an optional calling convention, a return type, an optional +parameter attributes), an optional section, an +optional alignment, an opening curly brace, a list of basic blocks, and a +closing curly brace. + +LLVM function declarations consist of the "declare" keyword, an +optional linkage type, an optional +visibility style, an optional +calling convention, a return type, an optional parameter attribute for the return type, a function name, a possibly empty list of arguments, and an optional alignment.

    @@ -641,7 +704,7 @@ basic block a symbol table entry), contains a list of instructions, and ends with a terminator instruction (such as a branch or function return).

    -

    The first basic block in a program is special in two ways: it is immediately +

    The first basic block in a function is special in two ways: it is immediately executed on entrance to the function, and it is not allowed to have predecessor basic blocks (i.e. there can not be any branches to the entry block of a function). Because the block can have no predecessors, it also cannot have any @@ -663,6 +726,29 @@ a power of 2.

    + + +
    + Aliases +
    +
    +

    Aliases act as "second name" for the aliasee value (which can be either + function or global variable or bitcast of global value). Aliases may have an + optional linkage type, and an + optional visibility style.

    + +
    Syntax:
    + +
    +
    +@<Name> = [Linkage] [Visibility] alias <AliaseeTy> @<Aliasee>
    +
    +
    + +
    + + +
    @@ -673,30 +759,50 @@ a power of 2.

    type so two functions types that differ only by the parameter attributes are different function types.

    -

    Parameter attributes consist of an at sign (@) followed by either a single - keyword or a comma separate list of keywords enclosed in parentheses. For - example:

    -    %someFunc = i16 @zext (i8 @(sext) %someParam)
    -    %someFunc = i16 @zext (i8 @zext %someParam)
    - Note that the two function types above are unique because the parameter - has a different attribute (@sext in the first one, @zext in the second).

    +

    Parameter attributes are simple keywords that follow the type specified. If + multiple parameter attributes are needed, they are space separated. For + example:

    + +
    +
    +%someFunc = i16 (i8 sext %someParam) zext
    +%someFunc = i16 (i8 zext %someParam) zext
    +
    +
    + +

    Note that the two function types above are unique because the parameter has + a different attribute (sext in the first one, zext in the second). Also note + that the attribute for the function result (zext) comes immediately after the + argument list.

    -

    Currently, only the following parameter attributes are defined: +

    Currently, only the following parameter attributes are defined:

    -
    @zext
    +
    zext
    This indicates that the parameter should be zero extended just before a call to this function.
    -
    @sext
    +
    sext
    This indicates that the parameter should be sign extended just before a call to this function.
    -

    +
    inreg
    +
    This indicates that the parameter should be placed in register (if + possible) during assembling function call. Support for this attribute is + target-specific
    +
    sret
    +
    This indicates that the parameter specifies the address of a structure + that is the return value of the function in the source program.
    +
    noalias
    +
    This indicates that the parameter not alias any other object or any + other "noalias" objects during the function call. +
    noreturn
    +
    This function attribute indicates that the function never returns. This + indicates to LLVM that every call to this function should be treated as if + an unreachable instruction immediately followed the call.
    +
    nounwind
    +
    This function attribute indicates that the function type does not use + the unwind instruction and does not allow stack unwinding to propagate + through it.
    + -

    The current motivation for parameter attributes is to enable the sign and - zero extend information necessary for the C calling convention to be passed - from the front end to LLVM. The @zext and @sext attributes - are used by the code generator to perform the required extension. However, - parameter attributes are an orthogonal feature to calling conventions and - may be used for other purposes in the future.

    @@ -712,10 +818,12 @@ LLVM and treated as a single unit, but may be separated in the .ll file if desired. The syntax is very simple:

    -
    -  module asm "inline asm code goes here"
    -  module asm "more can go here"
    -
    +
    +
    +module asm "inline asm code goes here"
    +module asm "more can go here"
    +
    +

    The strings can contain any character by escaping non-printable characters. The escape sequence used is simply "\xx" where "xx" is the two digit hex code @@ -728,6 +836,81 @@ desired. The syntax is very simple:

    + +
    + Data Layout +
    + +
    +

    A module may specify a target specific data layout string that specifies how +data is to be laid out in memory. The syntax for the data layout is simply:

    +
        target datalayout = "layout specification"
    +

    The layout specification consists of a list of specifications +separated by the minus sign character ('-'). Each specification starts with a +letter and may include other information after the letter to define some +aspect of the data layout. The specifications accepted are as follows:

    +
    +
    E
    +
    Specifies that the target lays out data in big-endian form. That is, the + bits with the most significance have the lowest address location.
    +
    e
    +
    Specifies that hte target lays out data in little-endian form. That is, + the bits with the least significance have the lowest address location.
    +
    p:size:abi:pref
    +
    This specifies the size of a pointer and its abi and + preferred alignments. All sizes are in bits. Specifying the pref + alignment is optional. If omitted, the preceding : should be omitted + too.
    +
    isize:abi:pref
    +
    This specifies the alignment for an integer type of a given bit + size. The value of size must be in the range [1,2^23).
    +
    vsize:abi:pref
    +
    This specifies the alignment for a vector type of a given bit + size.
    +
    fsize:abi:pref
    +
    This specifies the alignment for a floating point type of a given bit + size. The value of size must be either 32 (float) or 64 + (double).
    +
    asize:abi:pref
    +
    This specifies the alignment for an aggregate type of a given bit + size.
    +
    +

    When constructing the data layout for a given target, LLVM starts with a +default set of specifications which are then (possibly) overriden by the +specifications in the datalayout keyword. The default specifications +are given in this list:

    + +

    When llvm is determining the alignment for a given type, it uses the +following rules: +

      +
    1. If the type sought is an exact match for one of the specifications, that + specification is used.
    2. +
    3. If no match is found, and the type sought is an integer type, then the + smallest integer type that is larger than the bitwidth of the sought type is + used. If none of the specifications are larger than the bitwidth then the the + largest integer type is used. For example, given the default specifications + above, the i7 type will use the alignment of i8 (next largest) while both + i65 and i256 will use the alignment of i64 (largest specified).
    4. +
    5. If no match is found, and the type sought is a vector type, then the + largest vector type that is smaller than the sought vector type will be used + as a fall back. This happens because <128 x double> can be implemented in + terms of 64 <2 x double>, for example.
    6. +
    +
    Type System
    @@ -757,10 +940,7 @@ system. The current set of primitive types is as follows:

    - - - - +
    TypeDescription
    voidNo value
    i8Signless 8-bit value
    i32Signless 32-bit value
    float32-bit floating point value
    voidNo value
    labelBranch destination
    @@ -769,9 +949,7 @@ system. The current set of primitive types is as follows:

    - - - +
    TypeDescription
    boolTrue or False value
    i16Signless 16-bit value
    i64Signless 64-bit value
    float32-bit floating point value
    double64-bit floating point value
    @@ -792,12 +970,7 @@ classifications:

    ClassificationTypes integer - i8, i16, i32, i64 - - - integral - bool, i8, i16, i32, i64 - + i1, i2, i3, ... i8, ... i16, ... i32, ... i64, ... floating point @@ -805,8 +978,8 @@ classifications:

    first class - bool, i8, i16, i32, i64, float, double,
    - pointer,packed
    + i1, ..., float, double,
    + pointer,vector
    @@ -831,6 +1004,52 @@ recursive: For example, it is possible to have a two dimensional array.

    + +
    Integer Type
    + +
    + +
    Overview:
    +

    The integer type is a very simple derived type that simply specifies an +arbitrary bit width for the integer type desired. Any bit width from 1 bit to +2^23-1 (about 8 million) can be specified.

    + +
    Syntax:
    + +
    +  iN
    +
    + +

    The number of bits the integer will occupy is specified by the N +value.

    + +
    Examples:
    + + + + + +
    + i1
    + i4
    + i8
    + i16
    + i32
    + i42
    + i64
    + i1942652
    +
    + A boolean integer of 1 bit
    + A nibble sized integer of 4 bits.
    + A byte sized integer of 8 bits.
    + A half word sized integer of 16 bits.
    + A word sized integer of 32 bits.
    + An integer whose bit width is the answer.
    + A double word sized integer of 64 bits.
    + A really big integer of over 1 million bits.
    +
    +
    +
    Array Type
    @@ -857,12 +1076,12 @@ be any type with a size.

    [40 x i32 ]
    [41 x i32 ]
    - [40 x i32]
    + [40 x i8]
    - Array of 40 integer values.
    - Array of 41 integer values.
    - Array of 40 unsigned integer values.
    + Array of 40 32-bit integer values.
    + Array of 41 32-bit integer values.
    + Array of 40 8-bit integer values.
    @@ -872,12 +1091,12 @@ be any type with a size.

    [3 x [4 x i32]]
    [12 x [10 x float]]
    - [2 x [3 x [4 x i32]]]
    + [2 x [3 x [4 x i16]]]
    - 3x4 array of integer values.
    + 3x4 array of 32-bit integer values.
    12x10 array of single precision floating point values.
    - 2x3x4 array of unsigned integer values.
    + 2x3x4 array of 16-bit integer values.
    @@ -917,7 +1136,7 @@ Variable argument functions can access their arguments with the function taking an i32, returning an i32 - float (i16 @sext, i32 *) * + float (i16 sext, i32 *) * Pointer to a function that takes an i16 that should be sign extended and a @@ -927,7 +1146,7 @@ Variable argument functions can access their arguments with the i32 (i8*, ...) A vararg function that takes at least one - pointer to i8 (signed char in C), + pointer to i8 (char in C), which returns an integer. This is the signature for printf in LLVM. @@ -952,16 +1171,14 @@ instruction.

    Examples:
    - - + + + + +
    - { i32, i32, i32 }
    - { float, i32 (i32) * }
    -
    - a triple of three i32 values
    - A pair, where the first element is a float and the second element - is a pointer to a function - that takes an i32, returning an i32.
    -
    { i32, i32, i32 }A triple of three i32 values
    { float, i32 (i32) * }A pair, where the first element is a float and the + second element is a pointer to a + function that takes an i32, returning + an i32.
    @@ -984,16 +1201,14 @@ instruction.

    Examples:
    - - + + + + +
    - < { i32, i32, i32 } >
    - < { float, i32 (i32) * } >
    -
    - a triple of three i32 values
    - A pair, where the first element is a float and the second element - is a pointer to a function - that takes an i32, returning an i32.
    -
    < { i32, i32, i32 } >A triple of three i32 values
    < { float, i32 (i32) * } >A pair, where the first element is a float and the + second element is a pointer to a + function that takes an i32, returning + an i32.
    @@ -1025,17 +1240,17 @@ reference to another object, which must live in memory.

    - +
    Overview:
    -

    A packed type is a simple derived type that represents a vector -of elements. Packed types are used when multiple primitive data +

    A vector type is a simple derived type that represents a vector +of elements. Vector types are used when multiple primitive data are operated in parallel using a single instruction (SIMD). -A packed type requires a size (number of +A vector type requires a size (number of elements) and an underlying primitive data type. Vectors must have a power -of two length (1, 2, 4, 8, 16 ...). Packed types are +of two length (1, 2, 4, 8, 16 ...). Vector types are considered first class.

    Syntax:
    @@ -1045,7 +1260,7 @@ considered first class.

    The number of elements is a constant integer value; elementtype may -be any integral or floating point type.

    +be any integer or floating point type.

    Examples:
    @@ -1054,12 +1269,12 @@ be any integral or floating point type.

    <4 x i32>
    <8 x float>
    - <2 x i32>
    + <2 x i64>
    - Packed vector of 4 integer values.
    - Packed vector of 8 floating-point values.
    - Packed vector of 2 unsigned integer values.
    + Vector of 4 32-bit integer values.
    + Vector of 8 floating-point values.
    + Vector of 2 64-bit integer values.
    @@ -1117,13 +1332,13 @@ them all and their syntax.

    Boolean constants
    The two strings 'true' and 'false' are both valid - constants of the bool type. + constants of the i1 type.
    Integer constants
    Standard integers (such as '4') are constants of the integer type. Negative numbers may be used with signed + href="#t_integer">integer type. Negative numbers may be used with integer types.
    @@ -1181,13 +1396,13 @@ and smaller aggregate constants.

    types of elements must match those specified by the type. -
    Packed constants
    +
    Vector constants
    -
    Packed constants are represented with notation similar to packed type +
    Vector constants are represented with notation similar to vector type definitions (a comma separated list of elements, surrounded by less-than/greater-than's (<>)). For example: "< i32 42, - i32 11, i32 74, i32 100 >". Packed constants must have packed type, and the number and types of elements must + i32 11, i32 74, i32 100 >". Vector constants must have vector type, and the number and types of elements must match those specified by the type.
    @@ -1217,11 +1432,13 @@ href="#identifiers">identifier for the global is used and always have pointer type. For example, the following is a legal LLVM file:

    +
    -  %X = global i32 17
    -  %Y = global i32 42
    -  %Z = global [2 x i32*] [ i32* %X, i32* %Y ]
    +@X = global i32 17
    +@Y = global i32 42
    +@Z = global [2 x i32*] [ i32* @X, i32* @Y ]
     
    +
    @@ -1252,15 +1469,15 @@ following is the syntax for constant expressions:

    trunc ( CST to TYPE )
    Truncate a constant to another type. The bit size of CST must be larger - than the bit size of TYPE. Both types must be integral.
    + than the bit size of TYPE. Both types must be integers.
    zext ( CST to TYPE )
    Zero extend a constant to another type. The bit size of CST must be - smaller or equal to the bit size of TYPE. Both types must be integral.
    + smaller or equal to the bit size of TYPE. Both types must be integers.
    sext ( CST to TYPE )
    Sign extend a constant to another type. The bit size of CST must be - smaller or equal to the bit size of TYPE. Both types must be integral.
    + smaller or equal to the bit size of TYPE. Both types must be integers.
    fptrunc ( CST to TYPE )
    Truncate a floating point constant to another floating point type. The @@ -1307,7 +1524,7 @@ following is the syntax for constant expressions:

    identical (same number of bits). The conversion is done as if the CST value was stored to memory and read back as TYPE. In other words, no bits change with this operator, just the type. This can be used for conversion of - packed types to any other type, as long as they have the same bit width. For + vector types to any other type, as long as they have the same bit width. For pointers it is only valid to cast to another pointer type.
    @@ -1375,18 +1592,22 @@ indicates whether or not the inline asm expression has side effects. An example inline assembler expression is:

    +
    -  i32 (i32) asm "bswap $0", "=r,r"
    +i32 (i32) asm "bswap $0", "=r,r"
     
    +

    Inline assembler expressions may only be used as the callee operand of a call instruction. Thus, typically we have:

    +
    -  %X = call i32 asm "bswap $0", "=r,r"(i32 %Y)
    +%X = call i32 asm "bswap $0", "=r,r"(i32 %Y)
     
    +

    Inline asms with side effects not visible in the constraint list must be marked @@ -1394,9 +1615,11 @@ as having side effects. This is done through the use of the 'sideeffect' keyword, like so:

    +
    -  call void asm sideeffect "eieio", ""()
    +call void asm sideeffect "eieio", ""()
     
    +

    TODO: The format of the asm and constraints string still need to be documented here. Constraints on what can be done (e.g. duplication, moving, etc @@ -1479,7 +1702,7 @@ return value.

    Syntax:
    -
      br bool <cond>, label <iftrue>, label <iffalse>
    br label <dest> ; Unconditional branch +
      br i1 <cond>, label <iftrue>, label <iffalse>
    br label <dest> ; Unconditional branch
    Overview:

    The 'br' instruction is used to cause control flow to @@ -1488,16 +1711,16 @@ two forms of this instruction, corresponding to a conditional branch and an unconditional branch.

    Arguments:

    The conditional branch form of the 'br' instruction takes a -single 'bool' value and two 'label' values. The -unconditional form of the 'br' instruction takes a single 'label' -value as a target.

    +single 'i1' value and two 'label' values. The +unconditional form of the 'br' instruction takes a single +'label' value as a target.

    Semantics:
    -

    Upon execution of a conditional 'br' instruction, the 'bool' +

    Upon execution of a conditional 'br' instruction, the 'i1' argument is evaluated. If the value is true, control flows to the 'iftrue' label argument. If "cond" is false, control flows to the 'iffalse' label argument.

    Example:
    -
    Test:
    %cond = icmp eq, i32 %a, %b
    br bool %cond, label %IfEqual, label %IfUnequal
    IfEqual:
    Test:
    %cond =
    icmp eq, i32 %a, %b
    br i1 %cond, label %IfEqual, label %IfUnequal
    IfEqual:
    ret i32 1
    IfUnequal:
    ret i32 0
    @@ -1546,7 +1769,7 @@ branches or with a lookup table.

      ; Emulate a conditional br instruction
    - %Val = zext bool %value to i32
    + %Val = zext i1 %value to i32
      switch i32 %Val, label %truedest [i32 0, label %falsedest ]
     
      ; Emulate an unconditional br instruction
    @@ -1590,7 +1813,7 @@ continued at the dynamically nearest "exception" label.

    1. - The optional "cconv" marker indicates which calling + The optional "cconv" marker indicates which calling convention the call should use. If none is specified, the call defaults to using C calling conventions.
    2. @@ -1630,10 +1853,10 @@ exception. Additionally, this is important for implementation of
      Example:
      -  %retval = invoke i32 %Test(i32 15)             to label %Continue
      -              unwind label %TestCleanup     ; {i32}:retval set
      -  %retval = invoke coldcc i32 %Test(i32 15)             to label %Continue
      -              unwind label %TestCleanup     ; {i32}:retval set
      +  %retval = invoke i32 %Test(i32 15) to label %Continue
      +              unwind label %TestCleanup              ; {i32}:retval set
      +  %retval = invoke coldcc i32 %Test(i32 15) to label %Continue
      +              unwind label %TestCleanup              ; {i32}:retval set
       
      @@ -1699,7 +1922,7 @@ no-return function cannot be reached, and other facts.

      Binary operators are used to do most of the computation in a program. They require two operands, execute an operation on them, and produce a single value. The operands might represent -multiple data, as is the case with the packed data type. +multiple data, as is the case with the vector data type. The result value of a binary operator is not necessarily the same type as its operands.

      There are several different binary operators:

      @@ -1716,7 +1939,7 @@ Instruction
      Arguments:

      The two arguments to the 'add' instruction must be either integer or floating point values. - This instruction can also take packed versions of the values. + This instruction can also take vector versions of the values. Both arguments must have identical types.

      Semantics:

      The value produced is the integer or floating point sum of the two @@ -1741,13 +1964,14 @@ instruction present in most other intermediate representations.

      The two arguments to the 'sub' instruction must be either integer or floating point values. -This instruction can also take packed versions of the values. +This instruction can also take vector versions of the values. Both arguments must have identical types.

      Semantics:

      The value produced is the integer or floating point difference of the two operands.

      Example:
      -
        <result> = sub i32 4, %var          ; yields {i32}:result = 4 - %var
      +
      +  <result> = sub i32 4, %var          ; yields {i32}:result = 4 - %var
         <result> = sub i32 0, %val          ; yields {i32}:result = -%var
       
      @@ -1765,13 +1989,14 @@ operands.

      The two arguments to the 'mul' instruction must be either integer or floating point values. -This instruction can also take packed versions of the values. +This instruction can also take vector versions of the values. Both arguments must have identical types.

      Semantics:

      The value produced is the integer or floating point product of the two operands.

      -

      There is no signed vs unsigned multiplication. The appropriate -action is taken based on the type of the operand.

      +

      Because the operands are the same width, the result of an integer +multiplication is the same whether the operands should be deemed unsigned or +signed.

      Example:
        <result> = mul i32 4, %var          ; yields {i32}:result = 4 * %var
       
      @@ -1789,7 +2014,7 @@ operands.

      Arguments:

      The two arguments to the 'udiv' instruction must be integer values. Both arguments must have identical -types. This instruction can also take packed versions +types. This instruction can also take vector versions of the values in which case the elements must be integers.

      Semantics:

      The value produced is the unsigned integer quotient of the two operands. This @@ -1812,7 +2037,7 @@ operands.

      Arguments:

      The two arguments to the 'sdiv' instruction must be integer values. Both arguments must have identical -types. This instruction can also take packed versions +types. This instruction can also take vector versions of the values in which case the elements must be integers.

      Semantics:

      The value produced is the signed integer quotient of the two operands. This @@ -1833,10 +2058,10 @@ Instruction

      The 'fdiv' instruction returns the quotient of its two operands.

      Arguments:
      -

      The two arguments to the 'div' instruction must be +

      The two arguments to the 'fdiv' instruction must be floating point values. Both arguments must have -identical types. This instruction can also take packed -versions of the values in which case the elements must be floating point.

      +identical types. This instruction can also take vector +versions of floating point values.

      Semantics:

      The value produced is the floating point quotient of the two operands.

      Example:
      @@ -1882,11 +2107,13 @@ signed division of its two operands.

      types.

      Semantics:

      This instruction returns the remainder of a division (where the result -has the same sign as the divisor), not the modulus (where the -result has the same sign as the dividend) of a value. For more -information about the difference, see var1), not the modulo +operator (where the result has the same sign as the divisor, var2) of +a value. For more information about the difference, see The -Math Forum.

      +Math Forum. For a table of how this is implemented in various languages, +please see +Wikipedia: modulo operation.

      Example:
        <result> = srem i32 4, %var          ; yields {i32}:result = 4 % %var
       
      @@ -1924,6 +2151,89 @@ instructions. They require two operands, execute an operation on them, and produce a single value. The resulting value of the bitwise binary operators is always the same type as its first operand.

      + + + +
      +
      Syntax:
      +
        <result> = shl <ty> <var1>, <var2>   ; yields {ty}:result
      +
      +
      Overview:
      +

      The 'shl' instruction returns the first operand shifted to +the left a specified number of bits.

      +
      Arguments:
      +

      Both arguments to the 'shl' instruction must be the same integer type.

      +
      Semantics:
      +

      The value produced is var1 * 2var2.

      +
      Example:
      +  <result> = shl i32 4, %var   ; yields {i32}: 4 << %var
      +  <result> = shl i32 4, 2      ; yields {i32}: 16
      +  <result> = shl i32 1, 10     ; yields {i32}: 1024
      +
      +
      + + +
      +
      Syntax:
      +
        <result> = lshr <ty> <var1>, <var2>   ; yields {ty}:result
      +
      + +
      Overview:
      +

      The 'lshr' instruction (logical shift right) returns the first +operand shifted to the right a specified number of bits with zero fill.

      + +
      Arguments:
      +

      Both arguments to the 'lshr' instruction must be the same +integer type.

      + +
      Semantics:
      +

      This instruction always performs a logical shift right operation. The most +significant bits of the result will be filled with zero bits after the +shift.

      + +
      Example:
      +
      +  <result> = lshr i32 4, 1   ; yields {i32}:result = 2
      +  <result> = lshr i32 4, 2   ; yields {i32}:result = 1
      +  <result> = lshr i8  4, 3   ; yields {i8}:result = 0
      +  <result> = lshr i8 -2, 1   ; yields {i8}:result = 0x7FFFFFFF 
      +
      +
      + + + +
      + +
      Syntax:
      +
        <result> = ashr <ty> <var1>, <var2>   ; yields {ty}:result
      +
      + +
      Overview:
      +

      The 'ashr' instruction (arithmetic shift right) returns the first +operand shifted to the right a specified number of bits with sign extension.

      + +
      Arguments:
      +

      Both arguments to the 'ashr' instruction must be the same +integer type.

      + +
      Semantics:
      +

      This instruction always performs an arithmetic shift right operation, +The most significant bits of the result will be filled with the sign bit +of var1.

      + +
      Example:
      +
      +  <result> = ashr i32 4, 1   ; yields {i32}:result = 2
      +  <result> = ashr i32 4, 2   ; yields {i32}:result = 1
      +  <result> = ashr i8  4, 3   ; yields {i8}:result = 0
      +  <result> = ashr i8 -2, 1   ; yields {i8}:result = -1
      +
      +
      + @@ -1936,7 +2246,7 @@ Instruction its two operands.

      Arguments:

      The two arguments to the 'and' instruction must be integral values. Both arguments must have + href="#t_integer">integer values. Both arguments must have identical types.

      Semantics:

      The truth table used for the 'and' instruction is:

      @@ -1989,7 +2299,7 @@ identical types.

      or of its two operands.

      Arguments:

      The two arguments to the 'or' instruction must be integral values. Both arguments must have + href="#t_integer">integer values. Both arguments must have identical types.

      Semantics:

      The truth table used for the 'or' instruction is:

      @@ -2044,7 +2354,7 @@ or of its two operands. The xor is used to implement the "one's complement" operation, which is the "~" operator in C.

      Arguments:

      The two arguments to the 'xor' instruction must be integral values. Both arguments must have + href="#t_integer">integer values. Both arguments must have identical types.

      Semantics:

      The truth table used for the 'xor' instruction is:

      @@ -2088,89 +2398,6 @@ identical types.

      <result> = xor i32 %V, -1 ; yields {i32}:result = ~%V
      - - -
      -
      Syntax:
      -
        <result> = shl <ty> <var1>, i8 <var2>   ; yields {ty}:result
      -
      -
      Overview:
      -

      The 'shl' instruction returns the first operand shifted to -the left a specified number of bits.

      -
      Arguments:
      -

      The first argument to the 'shl' instruction must be an integer type. The second argument must be an 'i8' -type.

      -
      Semantics:
      -

      The value produced is var1 * 2var2.

      -
      Example:
      -
        <result> = shl i32 4, i8 %var   ; yields {i32}:result = 4 << %var
      -  <result> = shl i32 4, i8 2      ; yields {i32}:result = 16
      -  <result> = shl i32 1, i8 10     ; yields {i32}:result = 1024
      -
      -
      - - -
      -
      Syntax:
      -
        <result> = lshr <ty> <var1>, i8 <var2>   ; yields {ty}:result
      -
      - -
      Overview:
      -

      The 'lshr' instruction (logical shift right) returns the first -operand shifted to the right a specified number of bits.

      - -
      Arguments:
      -

      The first argument to the 'lshr' instruction must be an integer type. The second argument must be an 'i8' type.

      - -
      Semantics:
      -

      This instruction always performs a logical shift right operation, regardless -of whether the arguments are unsigned or not. The var2 most significant -bits will be filled with zero bits after the shift.

      - -
      Example:
      -
      -  <result> = lshr i32 4, i8 1   ; yields {i32}:result = 2
      -  <result> = lshr i32 4, i8 2    ; yields {i32}:result = 1
      -  <result> = lshr i8  4, i8 3  ; yields {i8 }:result = 0
      -  <result> = lshr i8  -2, i8 1 ; yields {i8 }:result = 0x7FFFFFFF 
      -
      -
      - - - -
      - -
      Syntax:
      -
        <result> = ashr <ty> <var1>, i8 <var2>   ; yields {ty}:result
      -
      - -
      Overview:
      -

      The 'ashr' instruction (arithmetic shift right) returns the first -operand shifted to the right a specified number of bits.

      - -
      Arguments:
      -

      The first argument to the 'ashr' instruction must be an -integer type. The second argument must be an -'i8' type.

      - -
      Semantics:
      -

      This instruction always performs an arithmetic shift right operation, -regardless of whether the arguments are signed or not. The var2 most -significant bits will be filled with the sign bit of var1.

      - -
      Example:
      -
      -  <result> = ashr i32 4, i8 1    ; yields {i32}:result = 2
      -  <result> = ashr i32 4, i8 2      ; yields {i32}:result = 1
      -  <result> = ashr i8 4, i8 3    ; yields {i8}:result = 0
      -  <result> = ashr i8  -2, i8 1   ; yields {i8 }:result = -1
      -
      -
      @@ -2180,7 +2407,7 @@ significant bits will be filled with the sign bit of var1.

      LLVM supports several instructions to represent vector operations in a -target-independent manner. This instructions cover the element-access and +target-independent manner. These instructions cover the element-access and vector-specific operations needed to process vectors effectively. While LLVM does directly support these vector operations, many sophisticated algorithms will want to use target-specific intrinsics to take full advantage of a specific @@ -2205,7 +2432,7 @@ target.

      The 'extractelement' instruction extracts a single scalar -element from a packed vector at a specified index. +element from a vector at a specified index.

      @@ -2213,7 +2440,7 @@ element from a packed vector at a specified index.

      The first operand of an 'extractelement' instruction is a -value of packed type. The second operand is +value of vector type. The second operand is an index indicating the position from which to extract the element. The index may be a variable.

      @@ -2251,7 +2478,7 @@ results are undefined.

      The 'insertelement' instruction inserts a scalar -element into a packed vector at a specified index. +element into a vector at a specified index.

      @@ -2259,7 +2486,7 @@ element into a packed vector at a specified index.

      The first operand of an 'insertelement' instruction is a -value of packed type. The second operand is a +value of vector type. The second operand is a scalar value whose type must equal the element type of the first operand. The third operand is an index indicating the position at which to insert the value. The index may be a variable.

      @@ -2267,7 +2494,7 @@ which to insert the value. The index may be a variable.

      Semantics:

      -The result is a packed vector of the same type as val. Its +The result is a vector of the same type as val. Its element values are those of val except at position idx, where it gets the value elt. If idx exceeds the length of val, the results are undefined. @@ -2328,7 +2555,7 @@ operand may be undef if performing a shuffle from only one vector.

         %result = shufflevector <4 x i32> %v1, <4 x i32> %v2, 
      -                          <4 x i32> <i32 0, i32 4, i32 1, i32 5>    ; yields <4 x i32>
      +                          <4 x i32> <i32 0, i32 4, i32 1, i32 5>  ; yields <4 x i32>
         %result = shufflevector <4 x i32> %v1, <4 x i32> undef, 
                                 <4 x i32> <i32 0, i32 1, i32 2, i32 3>  ; yields <4 x i32> - Identity shuffle.
       
      @@ -2390,11 +2617,11 @@ a pointer is returned.

         %array  = malloc [4 x i8 ]                    ; yields {[%4 x i8]*}:array
       
      -  %size   = add i32 2, 2                          ; yields {i32}:size = i32 4
      -  %array1 = malloc i8, i32 4                   ; yields {i8*}:array1
      -  %array2 = malloc [12 x i8], i32 %size        ; yields {[12 x i8]*}:array2
      -  %array3 = malloc i32, i32 4, align 1024         ; yields {i32*}:array3
      -  %array4 = malloc i32, align 1024                 ; yields {i32*}:array4
      +  %size   = add i32 2, 2                        ; yields {i32}:size = i32 4
      +  %array1 = malloc i8, i32 4                    ; yields {i8*}:array1
      +  %array2 = malloc [12 x i8], i32 %size         ; yields {[12 x i8]*}:array2
      +  %array3 = malloc i32, i32 4, align 1024       ; yields {i32*}:array3
      +  %array4 = malloc i32, align 1024              ; yields {i32*}:array4
       
      @@ -2450,8 +2677,8 @@ after this instruction executes.

      Overview:
      -

      The 'alloca' instruction allocates memory on the current -stack frame of the procedure that is live until the current function +

      The 'alloca' instruction allocates memory on the stack frame of the +currently executing function, to be automatically released when this function returns to its caller.

      Arguments:
      @@ -2479,8 +2706,8 @@ instructions), the memory is reclaimed.

         %ptr = alloca i32                              ; yields {i32*}:ptr
      -  %ptr = alloca i32, i32 4                      ; yields {i32*}:ptr
      -  %ptr = alloca i32, i32 4, align 1024          ; yields {i32*}:ptr
      +  %ptr = alloca i32, i32 4                       ; yields {i32*}:ptr
      +  %ptr = alloca i32, i32 4, align 1024           ; yields {i32*}:ptr
         %ptr = alloca i32, align 1024                  ; yields {i32*}:ptr
       
      @@ -2490,7 +2717,7 @@ instructions), the memory is reclaimed.

      Instruction
      Syntax:
      -
        <result> = load <ty>* <pointer>
      <result> = volatile load <ty>* <pointer>
      +
        <result> = load <ty>* <pointer>[, align <alignment>]
      <result> = volatile load <ty>* <pointer>[, align <alignment>]
      Overview:

      The 'load' instruction is used to read from memory.

      Arguments:
      @@ -2515,14 +2742,14 @@ instructions.

      Instruction
      Syntax:
      -
        store <ty> <value>, <ty>* <pointer>                   ; yields {void}
      -  volatile store <ty> <value>, <ty>* <pointer>                   ; yields {void}
      +
        store <ty> <value>, <ty>* <pointer>[, align <alignment>]                   ; yields {void}
      +  volatile store <ty> <value>, <ty>* <pointer>[, align <alignment>]          ; yields {void}
       
      Overview:

      The 'store' instruction is used to write to memory.

      Arguments:

      There are two arguments to the 'store' instruction: a value -to store and an address in which to store it. The type of the '<pointer>' +to store and an address at which to store it. The type of the '<pointer>' operand must be a pointer to the type of the '<value>' operand. If the store is marked as volatile, then the optimizer is not allowed to modify the number or order of execution of @@ -2570,37 +2797,39 @@ be sign extended to 64-bit values.

      For example, let's consider a C code fragment and how it gets compiled to LLVM:

      +
      -  struct RT {
      -    char A;
      -    i32 B[10][20];
      -    char C;
      -  };
      -  struct ST {
      -    i32 X;
      -    double Y;
      -    struct RT Z;
      -  };
      -
      -  define i32 *foo(struct ST *s) {
      -    return &s[1].Z.B[5][13];
      -  }
      +struct RT {
      +  char A;
      +  int B[10][20];
      +  char C;
      +};
      +struct ST {
      +  int X;
      +  double Y;
      +  struct RT Z;
      +};
      +
      +int *foo(struct ST *s) {
      +  return &s[1].Z.B[5][13];
      +}
       
      +

      The LLVM code generated by the GCC frontend is:

      +
      -  %RT = type { i8 , [10 x [20 x i32]], i8  }
      -  %ST = type { i32, double, %RT }
      -
      -  implementation
      +%RT = type { i8 , [10 x [20 x i32]], i8  }
      +%ST = type { i32, double, %RT }
       
      -  define i32* %foo(%ST* %s) {
      -  entry:
      -    %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13
      -    ret i32* %reg
      -  }
      +define i32* %foo(%ST* %s) {
      +entry:
      +  %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13
      +  ret i32* %reg
      +}
       
      +
      Semantics:
      @@ -2608,7 +2837,7 @@ compiled to LLVM:

      on the pointer type that is being indexed into. Pointer and array types can use a 32-bit or 64-bit integer type but the value will always be sign extended -to 64-bits. Structure types, require i32 +to 64-bits. Structure types require i32 constants.

      In the example above, the first index is indexing into the '%ST*' @@ -2628,8 +2857,8 @@ the LLVM code for the given testcase is equivalent to:

         define i32* %foo(%ST* %s) {
           %t1 = getelementptr %ST* %s, i32 1                        ; yields %ST*:%t1
      -    %t2 = getelementptr %ST* %t1, i32 0, i32 2               ; yields %RT*:%t2
      -    %t3 = getelementptr %RT* %t2, i32 0, i32 1               ; yields [10 x [20 x i32]]*:%t3
      +    %t2 = getelementptr %ST* %t1, i32 0, i32 2                ; yields %RT*:%t2
      +    %t3 = getelementptr %RT* %t2, i32 0, i32 1                ; yields [10 x [20 x i32]]*:%t3
           %t4 = getelementptr [10 x [20 x i32]]* %t3, i32 0, i32 5  ; yields [20 x i32]*:%t4
           %t5 = getelementptr [20 x i32]* %t4, i32 0, i32 13        ; yields i32*:%t5
           ret i32* %t5
      @@ -2683,7 +2912,7 @@ The 'trunc' instruction truncates its operand to the type ty2.
       

      The 'trunc' instruction takes a value to trunc, which must be an integer type, and a type that specifies the size -and type of the result, which must be an integral +and type of the result, which must be an integer type. The bit size of value must be larger than the bit size of ty2. Equal sized types are not allowed.

      @@ -2697,7 +2926,8 @@ It will always truncate bits.

      Example:
         %X = trunc i32 257 to i8              ; yields i8:1
      -  %Y = trunc i32 123 to bool               ; yields bool:true
      +  %Y = trunc i32 123 to i1              ; yields i1:true
      +  %Y = trunc i32 122 to i1              ; yields i1:false
       
      @@ -2719,24 +2949,21 @@ It will always truncate bits.

      Arguments:

      The 'zext' instruction takes a value to cast, which must be of -integral type, and a type to cast it to, which must -also be of integral type. The bit size of the +integer type, and a type to cast it to, which must +also be of integer type. The bit size of the value must be smaller than the bit size of the destination type, ty2.

      Semantics:

      The zext fills the high order bits of the value with zero -bits until it reaches the size of the destination type, ty2. When the -the operand and the type are the same size, no bit filling is done and the -cast is considered a no-op cast because no bits change (only the type -changes).

      +bits until it reaches the size of the destination type, ty2.

      -

      When zero extending from bool, the result will alwasy be either 0 or 1.

      +

      When zero extending from i1, the result will always be either 0 or 1.

      Example:
         %X = zext i32 257 to i64              ; yields i64:257
      -  %Y = zext bool true to i32              ; yields i32:1
      +  %Y = zext i1 true to i32              ; yields i32:1
       
      @@ -2757,8 +2984,8 @@ changes).

      Arguments:

      The 'sext' instruction takes a value to cast, which must be of -integral type, and a type to cast it to, which must -also be of integral type. The bit size of the +integer type, and a type to cast it to, which must +also be of integer type. The bit size of the value must be smaller than the bit size of the destination type, ty2.

      @@ -2766,16 +2993,14 @@ also be of integral type. The bit size of the

      The 'sext' instruction performs a sign extension by copying the sign bit (highest order bit) of the value until it reaches the bit size of -the type ty2. When the the operand and the type are the same size, -no bit filling is done and the cast is considered a no-op cast because -no bits change (only the type changes).

      +the type ty2.

      -

      When sign extending from bool, the extension always results in -1 or 0.

      +

      When sign extending from i1, the extension always results in -1 or 0.

      Example:
         %X = sext i8  -1 to i16              ; yields i16   :65535
      -  %Y = sext bool true to i32             ; yields i32:-1
      +  %Y = sext i1 true to i32             ; yields i32:-1
       
      @@ -2840,8 +3065,8 @@ type must be smaller than the destination type.

      Semantics:

      The 'fpext' instruction extends the value from a smaller -floating point type to a larger -floating point type. The fpext cannot be +floating point type to a larger +floating point type. The fpext cannot be used to make a no-op cast because it always changes bits. Use bitcast to make a no-op cast for a floating point cast.

      @@ -2854,7 +3079,7 @@ used to make a no-op cast because it always changes bits. Use
      @@ -2871,7 +3096,7 @@ unsigned integer equivalent of type ty2.
      Arguments:

      The 'fp2uint' instruction takes a value to cast, which must be a floating point value, and a type to cast it to, which -must be an integral type.

      +must be an integer type.

      Semantics:

      The 'fp2uint' instruction converts its @@ -2879,14 +3104,14 @@ must be an integral type.

      towards zero) unsigned integer value. If the value cannot fit in ty2, the results are undefined.

      -

      When converting to bool, the conversion is done as a comparison against -zero. If the value was zero, the bool result will be false. -If the value was non-zero, the bool result will be true.

      +

      When converting to i1, the conversion is done as a comparison against +zero. If the value was zero, the i1 result will be false. +If the value was non-zero, the i1 result will be true.

      Example:
      -  %X = fp2uint double 123.0 to i32         ; yields i32:123
      -  %Y = fp2uint float 1.0E+300 to bool      ; yields bool:true
      +  %X = fp2uint double 123.0 to i32      ; yields i32:123
      +  %Y = fp2uint float 1.0E+300 to i1     ; yields i1:true
         %X = fp2uint float 1.04E+17 to i8     ; yields undefined:1
       
      @@ -2911,7 +3136,7 @@ If the value was non-zero, the bool result will be true.

      Arguments:

      The 'fptosi' instruction takes a value to cast, which must be a floating point value, and a type to cast it to, which -must also be an integral type.

      +must also be an integer type.

      Semantics:

      The 'fptosi' instruction converts its @@ -2919,14 +3144,14 @@ must also be an integral type.

      towards zero) signed integer value. If the value cannot fit in ty2, the results are undefined.

      -

      When converting to bool, the conversion is done as a comparison against -zero. If the value was zero, the bool result will be false. -If the value was non-zero, the bool result will be true.

      +

      When converting to i1, the conversion is done as a comparison against +zero. If the value was zero, the i1 result will be false. +If the value was non-zero, the i1 result will be true.

      Example:
      -  %X = fptosi double -123.0 to i32        ; yields i32:-123
      -  %Y = fptosi float 1.0E-247 to bool      ; yields bool:true
      +  %X = fptosi double -123.0 to i32      ; yields i32:-123
      +  %Y = fptosi float 1.0E-247 to i1      ; yields i1:true
         %X = fptosi float 1.04E+17 to i8      ; yields undefined:1
       
      @@ -2949,7 +3174,7 @@ integer and converts that value to the ty2 type.

      Arguments:

      The 'uitofp' instruction takes a value to cast, which must be an -integral value, and a type to cast it to, which must +integer value, and a type to cast it to, which must be a floating point type.

      Semantics:
      @@ -2961,7 +3186,7 @@ the value cannot fit in the floating point value, the results are undefined.

      Example:
         %X = uitofp i32 257 to float         ; yields float:257.0
      -  %Y = uitofp i8  -1 to double       ; yields double:255.0
      +  %Y = uitofp i8  -1 to double         ; yields double:255.0
       
      @@ -2982,7 +3207,7 @@ integer and converts that value to the ty2 type.

      Arguments:

      The 'sitofp' instruction takes a value to cast, which must be an -integral value, and a type to cast it to, which must be +integer value, and a type to cast it to, which must be a floating point type.

      Semantics:
      @@ -2993,7 +3218,7 @@ the value cannot fit in the floating point value, the results are undefined.

      Example:
         %X = sitofp i32 257 to float         ; yields float:257.0
      -  %Y = sitofp i8  -1 to double       ; yields double:-1.0
      +  %Y = sitofp i8  -1 to double         ; yields double:-1.0
       
      @@ -3014,7 +3239,7 @@ the integer type ty2.

      Arguments:

      The 'ptrtoint' instruction takes a value to cast, which -must be a pointer value, and a type to cast it to +must be a pointer value, and a type to cast it to ty2, which must be an integer type.

      Semantics:
      @@ -3023,12 +3248,13 @@ must be a pointer value, and a type to cast it to truncating or zero extending that value to the size of the integer type. If value is smaller than ty2 then a zero extension is done. If value is larger than ty2 then a truncation is done. If they -are the same size, then nothing is done (no-op cast).

      +are the same size, then nothing is done (no-op cast) other than a type +change.

      Example:
      -  %X = ptrtoint i32* %X to i8           ; yields truncation on 32-bit
      -  %Y = ptrtoint i32* %x to i64          ; yields zero extend on 32-bit
      +  %X = ptrtoint i32* %X to i8           ; yields truncation on 32-bit architecture
      +  %Y = ptrtoint i32* %x to i64          ; yields zero extension on 32-bit architecture
       
      @@ -3048,9 +3274,9 @@ are the same size, then nothing is done (no-op cast).

      a pointer type, ty2.

      Arguments:
      -

      The 'inttoptr' instruction takes an integer +

      The 'inttoptr' instruction takes an integer value to cast, and a type to cast it to, which must be a -pointer type. +pointer type.

      Semantics:

      The 'inttoptr' instruction converts value to type @@ -3062,9 +3288,9 @@ nothing is done (no-op cast).

      Example:
      -  %X = inttoptr i32 255 to i32*            ; yields zero extend on 64-bit
      -  %X = inttoptr i32 255 to i32*            ; yields no-op on 32-bit 
      -  %Y = inttoptr i16 0 to i32*            ; yields zero extend on 32-bit
      +  %X = inttoptr i32 255 to i32*          ; yields zero extension on 64-bit architecture
      +  %X = inttoptr i32 255 to i32*          ; yields no-op on 32-bit architecture
      +  %Y = inttoptr i64 0 to i32*            ; yields truncation on 32-bit architecture
       
      @@ -3087,7 +3313,8 @@ nothing is done (no-op cast).

      The 'bitcast' instruction takes a value to cast, which must be a first class value, and a type to cast it to, which must also be a first class type. The bit sizes of value -and the destination type, ty2, must be identical.

      +and the destination type, ty2, must be identical. If the source +type is a pointer, the destination type must also be a pointer.

      Semantics:

      The 'bitcast' instruction converts value to type @@ -3100,7 +3327,7 @@ other types, use the inttoptr or

      Example:
      -  %X = bitcast i8 255 to i8          ; yields i8 :-1
      +  %X = bitcast i8 255 to i8              ; yields i8 :-1
         %Y = bitcast i32* %x to sint*          ; yields sint*:%x
         %Z = bitcast <2xint> %V to i64;        ; yields i64: %V   
       
      @@ -3118,15 +3345,15 @@ instructions, which defy better classification.

      Syntax:
      -
        <result> = icmp <cond> <ty> <var1>, <var2>   ; yields {bool}:result
      +
        <result> = icmp <cond> <ty> <var1>, <var2>   ; yields {i1}:result
       
      Overview:

      The 'icmp' instruction returns a boolean value based on comparison of its two integer operands.

      Arguments:

      The 'icmp' instruction takes three operands. The first operand is -the condition code which indicates the kind of comparison to perform. It is not -a value, just a keyword. The possibilities for the condition code are: +the condition code indicating the kind of comparison to perform. It is not +a value, just a keyword. The possible condition code are:

      1. eq: equal
      2. ne: not equal
      3. @@ -3139,12 +3366,12 @@ a value, just a keyword. The possibilities for the condition code are:
      4. slt: signed less than
      5. sle: signed less or equal
      -

      The remaining two arguments must be integral or +

      The remaining two arguments must be integer or pointer typed. They must also be identical types.

      Semantics:

      The 'icmp' compares var1 and var2 according to the condition code given as cond. The comparison performed always -yields a bool result, as follows: +yields a i1 result, as follows:

      1. eq: yields true if the operands are equal, false otherwise. No sign interpretation is necessary or performed. @@ -3167,13 +3394,9 @@ yields a bool result, as follows: true if var1 is less than var2.
      2. sle: interprets the operands as signed values and yields true if var1 is less than or equal to var2.
      3. -

      If the operands are pointer typed, the pointer -values are treated as integers and then compared.

      -

      If the operands are packed typed, the elements of -the vector are compared in turn and the predicate must hold for all -elements.

      +values are compared as if they were integers.

      Example:
        <result> = icmp eq i32 4, 5          ; yields: result=false
      @@ -3190,15 +3413,15 @@ elements.

      Syntax:
      -
        <result> = fcmp <cond> <ty> <var1>, <var2>   ; yields {bool}:result
      +
        <result> = fcmp <cond> <ty> <var1>, <var2>     ; yields {i1}:result
       
      Overview:

      The 'fcmp' instruction returns a boolean value based on comparison of its floating point operands.

      Arguments:

      The 'fcmp' instruction takes three operands. The first operand is -the condition code which indicates the kind of comparison to perform. It is not -a value, just a keyword. The possibilities for the condition code are: +the condition code indicating the kind of comparison to perform. It is not +a value, just a keyword. The possible condition code are:

      1. false: no comparison, always returns false
      2. oeq: ordered and equal
      3. @@ -3217,17 +3440,15 @@ a value, just a keyword. The possibilities for the condition code are:
      4. uno: unordered (either nans)
      5. true: no comparison, always returns true
      -

      In the preceding, ordered means that neither operand is a QNAN while +

      Ordered means that neither operand is a QNAN while unordered means that either operand may be a QNAN.

      The val1 and val2 arguments must be floating point typed. They must have identical types.

      -

      In the foregoing, ordered means that neither operand is a QNAN and -unordered means that either operand is a QNAN.

      Semantics:

      The 'fcmp' compares var1 and var2 according to the condition code given as cond. The comparison performed always -yields a bool result, as follows: +yields a i1 result, as follows:

      1. false: always yields false, regardless of operands.
      2. oeq: yields true if both operands are not a QNAN and @@ -3258,9 +3479,6 @@ yields a bool result, as follows:
      3. uno: yields true if either operand is a QNAN.
      4. true: always yields true, regardless of operands.
      -

      If the operands are packed typed, the elements of -the vector are compared in turn and the predicate must hold for all elements. -

      Example:
        <result> = fcmp oeq float 4.0, 5.0    ; yields: result=false
      @@ -3280,7 +3498,7 @@ Instruction 

      The 'phi' instruction is used to implement the φ node in the SSA graph representing the function.

      Arguments:
      -

      The type of the incoming values are specified with the first type +

      The type of the incoming values is specified with the first type field. After this, the 'phi' instruction takes a list of pairs as arguments, with one pair for each predecessor basic block of the current block. Only values of first class @@ -3290,9 +3508,9 @@ may be used as the label arguments.

      block and the PHI instructions: i.e. PHI instructions must be first in a basic block.

      Semantics:
      -

      At runtime, the 'phi' instruction logically takes on the -value specified by the parameter, depending on which basic block we -came from in the last terminator instruction.

      +

      At runtime, the 'phi' instruction logically takes on the value +specified by the pair corresponding to the predecessor basic block that executed +just prior to the current block.

      Example:
      Loop:       ; Infinite loop that counts from 0 on up...
      %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
      %nextindvar = add i32 %indvar, 1
      br label %Loop
      @@ -3307,7 +3525,7 @@ came from in the last terminator instruction.

      Syntax:
      -  <result> = select bool <cond>, <ty> <val1>, <ty> <val2>             ; yields ty
      +  <result> = select i1 <cond>, <ty> <val1>, <ty> <val2>             ; yields ty
       
      Overview:
      @@ -3334,7 +3552,7 @@ value argument; otherwise, it returns the second value argument.
      Example:
      -  %X = select bool true, i8 17, i8 42          ; yields i8:17
      +  %X = select i1 true, i8 17, i8 42          ; yields i8:17
       
      @@ -3368,7 +3586,7 @@ value argument; otherwise, it returns the second value argument. href="#i_ret">ret instruction.
    3. -

      The optional "cconv" marker indicates which calling +

      The optional "cconv" marker indicates which calling convention the call should use. If none is specified, the call defaults to using C calling conventions.

    4. @@ -3407,7 +3625,7 @@ the invoke instruction.

         %retval = call i32 %test(i32 %argc)
      -  call i32(i8 *, ...) *%printf(i8 * %msg, i32 12, i8  42);
      +  call i32(i8 *, ...) *%printf(i8 * %msg, i32 12, i8 42);
         %X = tail call i32 %foo()
         %Y = tail call fastcc i32 %foo()
       
      @@ -3437,7 +3655,7 @@ the "variable argument" area of a function call. It is used to implement the

      This instruction takes a va_list* value and the type of the argument. It returns a value of the specified argument type and -increments the va_list to point to the next argument. Again, the +increments the va_list to point to the next argument. The actual type of va_list is target specific.

      Semantics:
      @@ -3469,23 +3687,34 @@ argument.

      LLVM supports the notion of an "intrinsic function". These functions have -well known names and semantics and are required to follow certain -restrictions. Overall, these instructions represent an extension mechanism for -the LLVM language that does not require changing all of the transformations in -LLVM to add to the language (or the bytecode reader/writer, the parser, -etc...).

      +well known names and semantics and are required to follow certain restrictions. +Overall, these intrinsics represent an extension mechanism for the LLVM +language that does not require changing all of the transformations in LLVM when +adding to the language (or the bytecode reader/writer, the parser, etc...).

      Intrinsic function names must all start with an "llvm." prefix. This -prefix is reserved in LLVM for intrinsic names; thus, functions may not be named -this. Intrinsic functions must always be external functions: you cannot define -the body of intrinsic functions. Intrinsic functions may only be used in call -or invoke instructions: it is illegal to take the address of an intrinsic -function. Additionally, because intrinsic functions are part of the LLVM -language, it is required that they all be documented here if any are added.

      +prefix is reserved in LLVM for intrinsic names; thus, function names may not +begin with this prefix. Intrinsic functions must always be external functions: +you cannot define the body of intrinsic functions. Intrinsic functions may +only be used in call or invoke instructions: it is illegal to take the address +of an intrinsic function. Additionally, because intrinsic functions are part +of the LLVM language, it is required if any are added that they be documented +here.

      + +

      Some intrinsic functions can be overloaded, i.e., the intrinsic represents +a family of functions that perform the same operation but on different data +types. This is most frequent with the integer types. Since LLVM can represent +over 8 million different integer types, there is a way to declare an intrinsic +that can be overloaded based on its arguments. Such an intrinsic will have the +names of its argument types encoded into its function name, each +preceded by a period. For example, the llvm.ctpop function can take an +integer of any width. This leads to a family of functions such as +i32 @llvm.ctpop.i8(i8 %val) and i32 @llvm.ctpop.i29(i29 %val). +

      -

      To learn how to add an intrinsic function, please see the Extending LLVM Guide. +

      To learn how to add an intrinsic function, please see the +Extending LLVM Guide.

      @@ -3505,43 +3734,52 @@ named macros defined in the <stdarg.h> header file.

      All of these functions operate on arguments that use a target-specific value type "va_list". The LLVM assembly language reference manual does not define what this type is, so all -transformations should be prepared to handle intrinsics with any type -used.

      +transformations should be prepared to handle these functions regardless of +the type used.

      This example shows how the va_arg instruction and the variable argument handling intrinsic functions are used.

      +
      -define i32 %test(i32 %X, ...) {
      +define i32 @test(i32 %X, ...) {
         ; Initialize variable argument processing
      -  %ap = alloca i8 *
      -  call void %llvm.va_start(i8 ** %ap)
      +  %ap = alloca i8*
      +  %ap2 = bitcast i8** %ap to i8*
      +  call void @llvm.va_start(i8* %ap2)
       
         ; Read a single integer argument
      -  %tmp = va_arg i8 ** %ap, i32
      +  %tmp = va_arg i8** %ap, i32
       
         ; Demonstrate usage of llvm.va_copy and llvm.va_end
      -  %aq = alloca i8 *
      -  call void %llvm.va_copy(i8 ** %aq, i8 ** %ap)
      -  call void %llvm.va_end(i8 ** %aq)
      +  %aq = alloca i8*
      +  %aq2 = bitcast i8** %aq to i8*
      +  call void @llvm.va_copy(i8* %aq2, i8* %ap2)
      +  call void @llvm.va_end(i8* %aq2)
       
         ; Stop processing of arguments.
      -  call void %llvm.va_end(i8 ** %ap)
      +  call void @llvm.va_end(i8* %ap2)
         ret i32 %tmp
       }
      +
      +declare void @llvm.va_start(i8*)
      +declare void @llvm.va_copy(i8*, i8*)
      +declare void @llvm.va_end(i8*)
       
      + +
      Syntax:
      -
        declare void %llvm.va_start(<va_list>* <arglist>)
      +
        declare void %llvm.va_start(i8* <arglist>)
      Overview:

      The 'llvm.va_start' intrinsic initializes *<arglist> for subsequent use by va_arg.

      The 'llvm.va_start' intrinsic works just like the va_start macro available in C. In a target-dependent way, it initializes the -va_list element the argument points to, so that the next call to +va_list element to which the argument points, so that the next call to va_arg will produce the first variable argument passed to the function. Unlike the C va_start macro, this intrinsic does not need to know the -last argument of the function, the compiler can figure that out.

      +last argument of the function as the compiler can figure that out.

      Syntax:
      -
        declare void %llvm.va_end(<va_list*> <arglist>)
      +
        declare void @llvm.va_end(i8* <arglist>)
      Overview:
      -

      The 'llvm.va_end' intrinsic destroys <arglist> -which has been initialized previously with llvm.va_start + +

      The 'llvm.va_end' intrinsic destroys *<arglist>, +which has been initialized previously with llvm.va_start or llvm.va_copy.

      +
      Arguments:
      -

      The argument is a va_list to destroy.

      + +

      The argument is a pointer to a va_list to destroy.

      +
      Semantics:
      +

      The 'llvm.va_end' intrinsic works just like the va_end -macro available in C. In a target-dependent way, it destroys the va_list. -Calls to llvm.va_start and llvm.va_copy must be matched exactly -with calls to llvm.va_end.

      +macro available in C. In a target-dependent way, it destroys the +va_list element to which the argument points. Calls to llvm.va_start and +llvm.va_copy must be matched exactly with calls to +llvm.va_end.

      +
      @@ -3594,14 +3839,13 @@ with calls to llvm.va_end.

      Syntax:
      -  declare void %llvm.va_copy(<va_list>* <destarglist>,
      -                                          <va_list>* <srcarglist>)
      +  declare void @llvm.va_copy(i8* <destarglist>, i8* <srcarglist>)
       
      Overview:
      -

      The 'llvm.va_copy' intrinsic copies the current argument position from -the source argument list to the destination argument list.

      +

      The 'llvm.va_copy' intrinsic copies the current argument position +from the source argument list to the destination argument list.

      Arguments:
      @@ -3611,11 +3855,12 @@ The second argument is a pointer to a va_list element to copy from.

      Semantics:
      -

      The 'llvm.va_copy' intrinsic works just like the va_copy macro -available in C. In a target-dependent way, it copies the source -va_list element into the destination list. This intrinsic is necessary -because the llvm.va_begin intrinsic may be -arbitrarily complex and require memory allocation, for example.

      +

      The 'llvm.va_copy' intrinsic works just like the va_copy +macro available in C. In a target-dependent way, it copies the source +va_list element into the destination va_list element. This +intrinsic is necessary because the +llvm.va_start intrinsic may be arbitrarily complex and require, for +example, memory allocation.

      @@ -3629,9 +3874,9 @@ arbitrarily complex and require memory allocation, for example.

      LLVM support for Accurate Garbage Collection requires the implementation and generation of these intrinsics. -These intrinsics allow identification of GC roots on the +These intrinsics allow identification of GC roots on the stack, as well as garbage collector implementations that require read and write barriers. +href="#int_gcread">read and write barriers. Front-ends for type-safe garbage collected languages should generate these intrinsics to make use of the LLVM garbage collectors. For more details, see Accurate Garbage Collection with LLVM. @@ -3640,7 +3885,7 @@ href="GarbageCollection.html">Accurate Garbage Collection with LLVM.

      @@ -3648,7 +3893,7 @@ href="GarbageCollection.html">Accurate Garbage Collection with LLVM.
      Syntax:
      -  declare void %llvm.gcroot(<ty>** %ptrloc, <ty2>* %metadata)
      +  declare void @llvm.gcroot(<ty>** %ptrloc, <ty2>* %metadata)
       
      Overview:
      @@ -3674,7 +3919,7 @@ the runtime to find the pointer at GC safe points.
      @@ -3682,7 +3927,7 @@ the runtime to find the pointer at GC safe points.
      Syntax:
      -  declare i8 * %llvm.gcread(i8 * %ObjPtr, i8 ** %Ptr)
      +  declare i8 * @llvm.gcread(i8 * %ObjPtr, i8 ** %Ptr)
       
      Overview:
      @@ -3709,7 +3954,7 @@ garbage collector runtime, as needed.

      @@ -3717,7 +3962,7 @@ garbage collector runtime, as needed.

      Syntax:
      -  declare void %llvm.gcwrite(i8 * %P1, i8 * %Obj, i8 ** %P2)
      +  declare void @llvm.gcwrite(i8 * %P1, i8 * %Obj, i8 ** %P2)
       
      Overview:
      @@ -3758,14 +4003,14 @@ be implemented with code generator support.
      Syntax:
      -  declare i8  *%llvm.returnaddress(i32 <level>)
      +  declare i8  *@llvm.returnaddress(i32 <level>)
       
      Overview:
      @@ -3803,14 +4048,14 @@ source-language caller.
      Syntax:
      -  declare i8  *%llvm.frameaddress(i32 <level>)
      +  declare i8  *@llvm.frameaddress(i32 <level>)
       
      Overview:
      @@ -3846,21 +4091,21 @@ source-language caller.
      Syntax:
      -  declare i8  *%llvm.stacksave()
      +  declare i8  *@llvm.stacksave()
       
      Overview:

      The 'llvm.stacksave' intrinsic is used to remember the current state of -the function stack, for use with +the function stack, for use with llvm.stackrestore. This is useful for implementing language features like scoped automatic variable sized arrays in C99.

      @@ -3869,7 +4114,7 @@ features like scoped automatic variable sized arrays in C99.

      This intrinsic returns a opaque pointer value that can be passed to llvm.stackrestore. When an +href="#int_stackrestore">llvm.stackrestore. When an llvm.stackrestore intrinsic is executed with a value saved from llvm.stacksave, it effectively restores the state of the stack to the state it was in when the llvm.stacksave intrinsic executed. In @@ -3881,14 +4126,14 @@ that were allocated after the llvm.stacksave was executed.

      Syntax:
      -  declare void %llvm.stackrestore(i8 * %ptr)
      +  declare void @llvm.stackrestore(i8 * %ptr)
       
      Overview:
      @@ -3896,7 +4141,7 @@ that were allocated after the llvm.stacksave was executed.

      The 'llvm.stackrestore' intrinsic is used to restore the state of the function stack to the state it was in when the corresponding llvm.stacksave intrinsic executed. This is +href="#int_stacksave">llvm.stacksave intrinsic executed. This is useful for implementing language features like scoped automatic variable sized arrays in C99.

      @@ -3904,7 +4149,7 @@ arrays in C99.
      Semantics:

      -See the description for llvm.stacksave. +See the description for llvm.stacksave.

      @@ -3912,14 +4157,14 @@ See the description for llvm.stacksave.
      Syntax:
      -  declare void %llvm.prefetch(i8  * <address>,
      +  declare void @llvm.prefetch(i8  * <address>,
                                       i32 <rw>, i32 <locality>)
       
      @@ -3957,14 +4202,14 @@ performance.
      Syntax:
      -  declare void %llvm.pcmarker( i32 <id> )
      +  declare void @llvm.pcmarker( i32 <id> )
       
      Overview:
      @@ -3998,14 +4243,14 @@ support this intrinisic may ignore it.
      Syntax:
      -  declare i64 %llvm.readcyclecounter( )
      +  declare i64 @llvm.readcyclecounter( )
       
      Overview:
      @@ -4046,16 +4291,16 @@ for more efficient code generation.
      Syntax:
      -  declare void %llvm.memcpy.i32(i8 * <dest>, i8 * <src>,
      +  declare void @llvm.memcpy.i32(i8 * <dest>, i8 * <src>,
                                       i32 <len>, i32 <align>)
      -  declare void %llvm.memcpy.i64(i8 * <dest>, i8 * <src>,
      +  declare void @llvm.memcpy.i64(i8 * <dest>, i8 * <src>,
                                       i64 <len>, i32 <align>)
       
      @@ -4100,16 +4345,16 @@ be set to 0 or 1.
      Syntax:
      -  declare void %llvm.memmove.i32(i8 * <dest>, i8 * <src>,
      +  declare void @llvm.memmove.i32(i8 * <dest>, i8 * <src>,
                                        i32 <len>, i32 <align>)
      -  declare void %llvm.memmove.i64(i8 * <dest>, i8 * <src>,
      +  declare void @llvm.memmove.i64(i8 * <dest>, i8 * <src>,
                                        i64 <len>, i32 <align>)
       
      @@ -4155,16 +4400,16 @@ be set to 0 or 1.
      Syntax:
      -  declare void %llvm.memset.i32(i8 * <dest>, i8 <val>,
      +  declare void @llvm.memset.i32(i8 * <dest>, i8 <val>,
                                       i32 <len>, i32 <align>)
      -  declare void %llvm.memset.i64(i8 * <dest>, i8 <val>,
      +  declare void @llvm.memset.i64(i8 * <dest>, i8 <val>,
                                       i64 <len>, i32 <align>)
       
      @@ -4208,50 +4453,15 @@ this can be specified as the fourth argument, otherwise it should be set to 0 or
      Syntax:
      -  declare bool %llvm.isunordered.f32(float Val1, float  Val2)
      -  declare bool %llvm.isunordered.f64(double Val1, double Val2)
      -
      - -
      Overview:
      - -

      -The 'llvm.isunordered' intrinsics return true if either or both of the -specified floating point values is a NAN. -

      - -
      Arguments:
      - -

      -The arguments are floating point numbers of the same type. -

      - -
      Semantics:
      - -

      -If either or both of the arguments is a SNAN or QNAN, it returns true, otherwise -false. -

      -
      - - - - - -
      - -
      Syntax:
      -
      -  declare float %llvm.sqrt.f32(float %Val)
      -  declare double %llvm.sqrt.f64(double %Val)
      +  declare float @llvm.sqrt.f32(float %Val)
      +  declare double @llvm.sqrt.f64(double %Val)
       
      Overview:
      @@ -4279,15 +4489,15 @@ floating point number.
      Syntax:
      -  declare float  %llvm.powi.f32(float  %Val, i32 %power)
      -  declare double %llvm.powi.f64(double %Val, i32 %power)
      +  declare float  @llvm.powi.f32(float  %Val, i32 %power)
      +  declare double @llvm.powi.f64(double %Val, i32 %power)
       
      Overview:
      @@ -4328,35 +4538,40 @@ These allow efficient code generation for some algorithms.
      Syntax:
      +

      This is an overloaded intrinsic function. You can use bswap on any integer +type that is an even number of bytes (i.e. BitWidth % 16 == 0). Note the suffix +that includes the type for the result and the operand.

      -  declare i16 %llvm.bswap.i16(i16 <id>)
      -  declare i32 %llvm.bswap.i32(i32 <id>)
      -  declare i64 %llvm.bswap.i64(i64 <id>)
      +  declare i16 @llvm.bswap.i16.i16(i16 <id>)
      +  declare i32 @llvm.bswap.i32.i32(i32 <id>)
      +  declare i64 @llvm.bswap.i64.i64(i64 <id>)
       
      Overview:

      -The 'llvm.bwsap' family of intrinsics is used to byteswap a 16, 32 or -64 bit quantity. These are useful for performing operations on data that is not -in the target's native byte order. +The 'llvm.bswap' family of intrinsics is used to byte swap integer +values with an even number of bytes (positive multiple of 16 bits). These are +useful for performing operations on data that is not in the target's native +byte order.

      Semantics:

      -The llvm.bswap.16 intrinsic returns an i16 value that has the high +The llvm.bswap.16.i16 intrinsic returns an i16 value that has the high and low byte of the input i16 swapped. Similarly, the llvm.bswap.i32 intrinsic returns an i32 value that has the four bytes of the input i32 swapped, so that if the input bytes are numbered 0, 1, 2, 3 then the returned -i32 will have its bytes in 3, 2, 1, 0 order. The llvm.bswap.i64 -intrinsic extends this concept to 64 bits. +i32 will have its bytes in 3, 2, 1, 0 order. The llvm.bswap.i48.i48, +llvm.bswap.i64.i64 and other intrinsics extend this concept to +additional even-byte lengths (6 bytes, 8 bytes and more, respectively).

      @@ -4369,11 +4584,14 @@ intrinsic extends this concept to 64 bits.
      Syntax:
      +

      This is an overloaded intrinsic. You can use llvm.ctpop on any integer bit +width. Not all targets support all bit widths however.

      -  declare i8  %llvm.ctpop.i8 (i8  <src>)
      -  declare i16 %llvm.ctpop.i16(i16 <src>)
      -  declare i32 %llvm.ctpop.i32(i32 <src>)
      -  declare i64 %llvm.ctpop.i64(i64 <src>)
      +  declare i32 @llvm.ctpop.i8 (i8  <src>)
      +  declare i32 @llvm.ctpop.i16(i16 <src>)
      +  declare i32 @llvm.ctpop.i32(i32 <src>)
      +  declare i32 @llvm.ctpop.i64(i64 <src>)
      +  declare i32 @llvm.ctpop.i256(i256 <src>)
       
      Overview:
      @@ -4387,7 +4605,7 @@ value.

      The only argument is the value to be counted. The argument may be of any -unsigned integer type. The return type must match the argument type. +integer type. The return type must match the argument type.

      Semantics:
      @@ -4405,11 +4623,14 @@ The 'llvm.ctpop' intrinsic counts the 1's in a variable.
      Syntax:
      +

      This is an overloaded intrinsic. You can use llvm.ctlz on any +integer bit width. Not all targets support all bit widths however.

      -  declare i8  %llvm.ctlz.i8 (i8  <src>)
      -  declare i16 %llvm.ctlz.i16(i16 <src>)
      -  declare i32 %llvm.ctlz.i32(i32 <src>)
      -  declare i64 %llvm.ctlz.i64(i64 <src>)
      +  declare i32 @llvm.ctlz.i8 (i8  <src>)
      +  declare i32 @llvm.ctlz.i16(i16 <src>)
      +  declare i32 @llvm.ctlz.i32(i32 <src>)
      +  declare i32 @llvm.ctlz.i64(i64 <src>)
      +  declare i32 @llvm.ctlz.i256(i256 <src>)
       
      Overview:
      @@ -4423,7 +4644,7 @@ leading zeros in a variable.

      The only argument is the value to be counted. The argument may be of any -unsigned integer type. The return type must match the argument type. +integer type. The return type must match the argument type.

      Semantics:
      @@ -4445,11 +4666,14 @@ of src. For example, llvm.ctlz(i32 2) = 30.
      Syntax:
      +

      This is an overloaded intrinsic. You can use llvm.cttz on any +integer bit width. Not all targets support all bit widths however.

      -  declare i8  %llvm.cttz.i8 (i8  <src>)
      -  declare i16 %llvm.cttz.i16(i16 <src>)
      -  declare i32 %llvm.cttz.i32(i32 <src>)
      -  declare i64 %llvm.cttz.i64(i64 <src>)
      +  declare i32 @llvm.cttz.i8 (i8  <src>)
      +  declare i32 @llvm.cttz.i16(i16 <src>)
      +  declare i32 @llvm.cttz.i32(i32 <src>)
      +  declare i32 @llvm.cttz.i64(i64 <src>)
      +  declare i32 @llvm.cttz.i256(i256 <src>)
       
      Overview:
      @@ -4463,7 +4687,7 @@ trailing zeros.

      The only argument is the value to be counted. The argument may be of any -unsigned integer type. The return type must match the argument type. +integer type. The return type must match the argument type.

      Semantics:
      @@ -4475,6 +4699,105 @@ of src. For example, llvm.cttz(2) = 1.

      + + + +
      + +
      Syntax:
      +

      This is an overloaded intrinsic. You can use llvm.part.select +on any integer bit width. +

      +  declare i17 @llvm.part.select.i17.i17 (i17 %val, i32 %loBit, i32 %hiBit)
      +  declare i29 @llvm.part.select.i29.i29 (i29 %val, i32 %loBit, i32 %hiBit)
      +
      + +
      Overview:
      +

      The 'llvm.part.select' family of intrinsic functions selects a +range of bits from an integer value and returns them in the same bit width as +the original value.

      + +
      Arguments:
      +

      The first argument, %val and the result may be integer types of +any bit width but they must have the same bit width. The second and third +arguments must be i32 type since they specify only a bit index.

      + +
      Semantics:
      +

      The operation of the 'llvm.part.select' intrinsic has two modes +of operation: forwards and reverse. If %loBit is greater than +%hiBits then the intrinsic operates in reverse mode. Otherwise it +operates in forward mode.

      +

      In forward mode, this intrinsic is the equivalent of shifting %val +right by %loBit bits and then ANDing it with a mask with +only the %hiBit - %loBit bits set, as follows:

      +
        +
      1. The %val is shifted right (LSHR) by the number of bits specified + by %loBits. This normalizes the value to the low order bits.
      2. +
      3. The %loBits value is subtracted from the %hiBits value + to determine the number of bits to retain.
      4. +
      5. A mask of the retained bits is created by shifting a -1 value.
      6. +
      7. The mask is ANDed with %val to produce the result. +
      +

      In reverse mode, a similar computation is made except that the bits are +returned in the reverse order. So, for example, if X has the value +i16 0x0ACF (101011001111) and we apply +part.select(i16 X, 8, 3) to it, we get back the value +i16 0x0026 (000000100110).

      +
      + + + +
      + +
      Syntax:
      +

      This is an overloaded intrinsic. You can use llvm.part.set +on any integer bit width. +

      +  declare i17 @llvm.part.set.i17.i17.i9 (i17 %val, i9 %repl, i32 %lo, i32 %hi)
      +  declare i29 @llvm.part.set.i29.i29.i9 (i29 %val, i9 %repl, i32 %lo, i32 %hi)
      +
      + +
      Overview:
      +

      The 'llvm.part.set' family of intrinsic functions replaces a range +of bits in an integer value with another integer value. It returns the integer +with the replaced bits.

      + +
      Arguments:
      +

      The first argument, %val and the result may be integer types of +any bit width but they must have the same bit width. %val is the value +whose bits will be replaced. The second argument, %repl may be an +integer of any bit width. The third and fourth arguments must be i32 +type since they specify only a bit index.

      + +
      Semantics:
      +

      The operation of the 'llvm.part.set' intrinsic has two modes +of operation: forwards and reverse. If %lo is greater than +%hi then the intrinsic operates in reverse mode. Otherwise it +operates in forward mode.

      +

      For both modes, the %repl value is prepared for use by either +truncating it down to the size of the replacement area or zero extending it +up to that size.

      +

      In forward mode, the bits between %lo and %hi (inclusive) +are replaced with corresponding bits from %repl. That is the 0th bit +in %repl replaces the %loth bit in %val and etc. up +to the %hith bit. +

      In reverse mode, a similar computation is made except that the bits are +reversed. That is, the 0th bit in %repl replaces the +%hi bit in %val and etc. down to the %loth bit. +

      Examples:
      +
      +  llvm.part.set(0xFFFF, 0, 4, 7) -> 0xFF0F
      +  llvm.part.set(0xFFFF, 0, 7, 4) -> 0xFF0F
      +  llvm.part.set(0xFFFF, 1, 7, 4) -> 0xFF8F
      +  llvm.part.set(0xFFFF, F, 8, 3) -> 0xFFE7
      +  llvm.part.set(0xFFFF, 0, 3, 8) -> 0xFE07
      +
      +
      +
      Debugger Intrinsics @@ -4490,6 +4813,64 @@ Debugging document.
      + + + +
      +

      The LLVM exception handling intrinsics (which all start with +llvm.eh. prefix), are described in the LLVM Exception +Handling document.

      +
      + + + + +
      +

      This class of intrinsics is designed to be generic and has +no specific purpose.

      +
      + + + + +
      + +
      Syntax:
      +
      +  declare void @llvm.var.annotation(i8* <val>, i8* <str>, i8* <str>, i32  <int> )
      +
      + +
      Overview:
      + +

      +The 'llvm.var.annotation' intrinsic +

      + +
      Arguments:
      + +

      +The first argument is a pointer to a value, the second is a pointer to a +global string, the third is a pointer to a global string which is the source +file name, and the last argument is the line number. +

      + +
      Semantics:
      + +

      +This intrinsic allows annotation of local variables with arbitrary strings. +This can be useful for special purpose optimizations that want to look for these + annotations. These have no other defined use, they are ignored by code + generation and optimization. +

      + +