X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=89b9227b722e8d7a136e0224bb9227fe15e489b4;hb=85042e658558e32a168a91379d158e6d694d6530;hp=71a0a7d6c63c61fe9149900b0d0a58b86f080cfc;hpb=9ae7563732b05eb81b2fdf6b9941106005155d5b;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index 71a0a7d6c63..89b9227b722 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -7,7 +7,7 @@ - + @@ -25,7 +25,6 @@
  • 'private' Linkage
  • 'linker_private' Linkage
  • 'linker_private_weak' Linkage
  • -
  • 'linker_private_weak_def_auto' Linkage
  • 'internal' Linkage
  • 'available_externally' Linkage
  • 'linkonce' Linkage
  • @@ -34,6 +33,7 @@
  • 'appending' Linkage
  • 'extern_weak' Linkage
  • 'linkonce_odr' Linkage
  • +
  • 'linkonce_odr_auto_hide' Linkage
  • 'weak_odr' Linkage
  • 'external' Linkage
  • 'dllimport' Linkage
  • @@ -92,7 +92,7 @@
  • Complex Constants
  • Global Variable and Function Addresses
  • Undefined Values
  • -
  • Trap Values
  • +
  • Poison Values
  • Addresses of Basic Blocks
  • Constant Expressions
  • @@ -103,11 +103,18 @@
  • Metadata Nodes and Metadata Strings
    1. 'tbaa' Metadata
    2. -
    3. 'fpaccuracy' Metadata
    4. +
    5. 'tbaa.struct' Metadata
    6. +
    7. 'fpmath' Metadata
    8. +
    9. 'range' Metadata
  • +
  • Module Flags Metadata +
      +
    1. Objective-C Garbage Collection Module Flags Metadata
    2. +
    +
  • Intrinsic Global Variables
    1. The 'llvm.used' Global Variable
    2. @@ -128,7 +135,6 @@
    3. 'switch' Instruction
    4. 'indirectbr' Instruction
    5. 'invoke' Instruction
    6. -
    7. 'unwind' Instruction
    8. 'resume' Instruction
    9. 'unreachable' Instruction
    @@ -252,6 +258,8 @@
  • 'llvm.exp.*' Intrinsic
  • 'llvm.log.*' Intrinsic
  • 'llvm.fma.*' Intrinsic
  • +
  • 'llvm.fabs.*' Intrinsic
  • +
  • 'llvm.floor.*' Intrinsic
  • Bit Manipulation Intrinsics @@ -272,6 +280,11 @@
  • 'llvm.umul.with.overflow.* Intrinsics
  • +
  • Specialised Arithmetic Intrinsics +
      +
    1. 'llvm.fmuladd Intrinsic
    2. +
    +
  • Half Precision Floating Point Intrinsics
    1. 'llvm.convert.to.fp16' Intrinsic
    2. @@ -288,10 +301,10 @@
    3. Memory Use Markers
        -
      1. llvm.lifetime.start
      2. -
      3. llvm.lifetime.end
      4. -
      5. llvm.invariant.start
      6. -
      7. llvm.invariant.end
      8. +
      9. 'llvm.lifetime.start' Intrinsic
      10. +
      11. 'llvm.lifetime.end' Intrinsic
      12. +
      13. 'llvm.invariant.start' Intrinsic
      14. +
      15. 'llvm.invariant.end' Intrinsic
    4. General intrinsics @@ -302,10 +315,16 @@ 'llvm.annotation.*' Intrinsic
    5. 'llvm.trap' Intrinsic
    6. +
    7. + 'llvm.debugtrap' Intrinsic
    8. 'llvm.stackprotector' Intrinsic
    9. -
    10. +
    11. 'llvm.objectsize' Intrinsic
    12. +
    13. + 'llvm.expect' Intrinsic
    14. +
    15. + 'llvm.donothing' Intrinsic
  • @@ -484,43 +503,43 @@
    -

    LLVM programs are composed of "Module"s, each of which is a translation unit - of the input programs. Each module consists of functions, global variables, - and symbol table entries. Modules may be 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:

    +

    LLVM programs are composed of Modules, each of which is a + translation unit of the input programs. Each module consists of functions, + global variables, and symbol table entries. Modules may be 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]* 
    +@.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00" 
     
     ; External declaration of the puts function 
    -declare i32 @puts(i8*)                                      ; i32 (i8*)*  
    +declare i32 @puts(i8* nocapture) nounwind 
     
     ; Definition of main function
     define i32 @main() {   ; i32()*  
       ; Convert [13 x i8]* to i8  *... 
    -  %cast210 = getelementptr [13 x i8]* @.LC0, i64 0, i64 0   ; i8* 
    +  %cast210 = getelementptr [13 x i8]* @.str, i64 0, i64 0
     
       ; Call puts function to write out the string to stdout. 
    -  call i32 @puts(i8* %cast210)           ; i32 
    +  call i32 @puts(i8* %cast210)
       ret i32 0 
     }
     
     ; Named metadata
    -!1 = metadata !{i32 41}
    +!1 = metadata !{i32 42}
     !foo = !{!1, null}
     

    This example is made up of a global variable named - ".LC0", an external declaration of the "puts" function, + ".str", an external declaration of the "puts" function, a function definition for "main" and named metadata - "foo".

    + "foo".

    -

    In general, a module is made up of a list of global values, where both - functions and global variables are global values. Global values are +

    In general, a module is made up of a list of global values (where both + functions and global variables are global values). Global values are 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.

    @@ -558,15 +577,6 @@ define i32 @main() { ; i32()*   linker. The symbols are removed by the linker from the final linked image (executable or dynamic library). -
    linker_private_weak_def_auto
    -
    Similar to "linker_private_weak", but it's known that the address - of the object is not taken. For instance, functions that had an inline - definition, but the compiler decided not to inline it. Note, - unlike linker_private and linker_private_weak, - linker_private_weak_def_auto may have only default - visibility. The symbols are removed by the linker from the final linked - image (executable or dynamic library).
    -
    internal
    Similar to private, but the value shows as a local symbol (STB_LOCAL in the case of ELF) in the object file. This @@ -635,6 +645,14 @@ define i32 @main() { ; i32()*   be merged with equivalent globals. These linkage types are otherwise the same as their non-odr versions.
    +
    linkonce_odr_auto_hide
    +
    Similar to "linkonce_odr", but nothing in the translation unit + takes the address of this definition. For instance, functions that had an + inline definition, but the compiler decided not to inline it. + linkonce_odr_auto_hide may have only default visibility. + The symbols are removed by the linker from the final linked image + (executable or dynamic library).
    +
    external
    If none of the above identifiers are used, the global is externally visible, meaning that it participates in linkage and can be used to @@ -824,9 +842,32 @@ define i32 @main() { ; i32()*  

    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 "thread_local", which + 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 + separated copy of the variable). Not all targets support thread-local + variables. Optionally, a TLS model may be specified:

    + +
    +
    localdynamic:
    +
    For variables that are only used within the current shared library.
    + +
    initialexec:
    +
    For variables in modules that will not be loaded dynamically.
    + +
    localexec:
    +
    For variables defined in the executable and only used within it.
    +
    + +

    The models correspond to the ELF TLS models; see + ELF + Handling For Thread-Local Storage for more information on under which + circumstances the different models may be used. The target may choose a + different TLS model if the specified model is not supported, or if a better + choice of model can be made.

    + +

    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). @@ -879,6 +920,13 @@ define i32 @main() { ; i32()*   @G = addrspace(5) constant float 1.0, section "foo", align 4 +

    The following example defines a thread-local global with + the initialexec TLS model:

    + +
    +@G = thread_local(initialexec) global i32 0, align 4
    +
    +
    @@ -1041,7 +1089,7 @@ declare signext i8 @returns_signed_char() value to the function. The attribute implies that a hidden copy of the pointee is made between the caller and the callee, so the callee is unable to - modify the value in the callee. This attribute is only valid on LLVM + modify the value in the caller. This attribute is only valid on LLVM pointer arguments. It is generally used to pass structs and arrays by value, but is also valid on pointers to scalars. The copy is considered to belong to the caller not the callee (for example, @@ -1141,6 +1189,10 @@ define void @f() optsize { ... }
    +
    address_safety
    +
    This attribute indicates that the address safety analysis + is enabled for this function.
    +
    alignstack(<n>)
    This attribute indicates that, when emitting the prologue and epilogue, the backend should forcibly align the stack pointer. Specify the @@ -1200,8 +1252,7 @@ define void @f() optsize { ... } It does not write through any pointer arguments (including byval arguments) and never changes any state visible to callers. This means that it cannot unwind - exceptions by calling the C++ exception throwing methods, but - could use the unwind instruction.
    + exceptions by calling the C++ exception throwing methods.
    readonly
    This attribute indicates that the function does not write through any @@ -1211,8 +1262,13 @@ define void @f() optsize { ... } and read state that may be set in the caller. A readonly function always returns the same value (or unwinds an exception identically) when called with the same set of arguments and global state. It cannot unwind an - exception by calling the C++ exception throwing methods, but may - use the unwind instruction.
    + exception by calling the C++ exception throwing methods. + +
    returns_twice
    +
    This attribute indicates that this function can return twice. The + C setjmp is an example of such a function. The compiler + disables some optimizations (like tail calls) in the caller of these + functions.
    ssp
    This attribute indicates that the function should emit a stack smashing @@ -1241,12 +1297,6 @@ define void @f() optsize { ... } show that no exceptions passes by it. This is normally the case for the ELF x86-64 abi, but it can be disabled for some compilation units.
    - -
    returns_twice
    -
    This attribute indicates that this function can return - twice. The C setjmp is an example of such a function. - The compiler disables some optimizations (like tail calls) in the caller of - these functions.
    @@ -1383,7 +1433,7 @@ target datalayout = "layout specification"
  • 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 + 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).
  • @@ -1608,7 +1658,7 @@ that determines which other atomic instructions on the same address they synchronize with. These semantics are borrowed from Java and C++0x, but are somewhat more colloquial. If these descriptions aren't precise enough, check those specs (see spec references in the -atomics guide). +atomics guide). fence instructions treat these orderings somewhat differently since they don't take an address. See that instruction's documentation for details.

    @@ -1707,7 +1757,7 @@ in signal handlers).

    floating point - float, double, x86_fp80, fp128, ppc_fp128 + half, float, double, x86_fp80, fp128, ppc_fp128 first class @@ -1807,6 +1857,7 @@ in signal handlers).

    + @@ -1911,9 +1962,9 @@ in signal handlers).

    Aggregate Types are a subset of derived types that can contain multiple - member types. Arrays, - structs, and vectors are - aggregate types.

    + member types. Arrays and + structs are aggregate types. + Vectors are not considered to be aggregate types.

    @@ -2187,8 +2238,8 @@ in signal handlers).

    The number of elements is a constant integer value larger than 0; elementtype - may be any integer or floating point type. Vectors of size zero are not - allowed, and pointers are not allowed as the element type.

    + may be any integer or floating point type, or a pointer to these types. + Vectors of size zero are not allowed.

    Examples:
    TypeDescription
    half16-bit floating point value
    float32-bit floating point value
    double64-bit floating point value
    fp128128-bit floating point value (112-bit mantissa)
    @@ -2204,6 +2255,10 @@ in signal handlers).

    + + + +
    <2 x i64> Vector of 2 64-bit integer values.
    <4 x i64*>Vector of 4 pointers to 64-bit integer values.
    @@ -2262,18 +2317,20 @@ in signal handlers).

    represented in their IEEE hexadecimal format so that assembly and disassembly do not cause any bits to change in the constants.

    -

    When using the hexadecimal form, constants of types float and double are +

    When using the hexadecimal form, constants of types half, float, and double are represented using the 16-digit form shown above (which matches the IEEE754 - representation for double); float values must, however, be exactly - representable as IEE754 single precision. Hexadecimal format is always used + representation for double); half and float values must, however, be exactly + representable as IEE754 half and single precision, respectively. + Hexadecimal format is always used for long double, and there are three forms of long double. The 80-bit format used by x86 is represented as 0xK followed by 20 hexadecimal digits. The 128-bit format used by PowerPC (two adjacent doubles) is represented by 0xM followed by 32 hexadecimal digits. The IEEE 128-bit format is represented by 0xL followed by 32 hexadecimal digits; no currently supported target uses this format. Long doubles will only work if - they match the long double format on your target. All hexadecimal formats - are big-endian (sign bit at the left).

    + they match the long double format on your target. The IEEE 16-bit format + (half precision) is represented by 0xH followed by 4 hexadecimal + digits. All hexadecimal formats are big-endian (sign bit at the left).

    There are no constants of type x86mmx.

    @@ -2500,22 +2557,21 @@ b: unreachable

    - Trap Values + Poison Values

    -

    Trap values are similar to undef values, however - instead of representing an unspecified bit pattern, they represent the - fact that an instruction or constant expression which cannot evoke side - effects has nevertheless detected a condition which results in undefined - behavior.

    +

    Poison values are similar to undef values, however + they also represent the fact that an instruction or constant expression which + cannot evoke side effects has nevertheless detected a condition which results + in undefined behavior.

    -

    There is currently no way of representing a trap value in the IR; they +

    There is currently no way of representing a poison value in the IR; they only exist when produced by operations such as add with the nsw flag.

    -

    Trap value behavior is defined in terms of value dependence:

    +

    Poison value behavior is defined in terms of value dependence:

    -

    Whenever a trap value is generated, all values which depend on it evaluate - to trap. If they have side effects, they evoke their side effects as if each - operand with a trap value were undef. If they have externally-visible side - effects, the behavior is undefined.

    +

    Poison Values have the same behavior as undef values, + with the additional affect that any instruction which has a dependence + on a poison value has undefined behavior.

    Here are some examples:

     entry:
    -  %trap = sub nuw i32 0, 1           ; Results in a trap value.
    -  %still_trap = and i32 %trap, 0     ; Whereas (and i32 undef, 0) would return 0.
    -  %trap_yet_again = getelementptr i32* @h, i32 %still_trap
    -  store i32 0, i32* %trap_yet_again  ; undefined behavior
    +  %poison = sub nuw i32 0, 1           ; Results in a poison value.
    +  %still_poison = and i32 %poison, 0   ; 0, but also poison.
    +  %poison_yet_again = getelementptr i32* @h, i32 %still_poison
    +  store i32 0, i32* %poison_yet_again  ; memory at @h[0] is poisoned
     
    -  store i32 %trap, i32* @g           ; Trap value conceptually stored to memory.
    -  %trap2 = load i32* @g              ; Returns a trap value, not just undef.
    +  store i32 %poison, i32* @g           ; Poison value stored to memory.
    +  %poison2 = load i32* @g              ; Poison value loaded back from memory.
     
    -  volatile store i32 %trap, i32* @g  ; External observation; undefined behavior.
    +  store volatile i32 %poison, i32* @g  ; External observation; undefined behavior.
     
       %narrowaddr = bitcast i32* @g to i16*
       %wideaddr = bitcast i32* @g to i64*
    -  %trap3 = load i16* %narrowaddr     ; Returns a trap value.
    -  %trap4 = load i64* %wideaddr       ; Returns a trap value.
    +  %poison3 = load i16* %narrowaddr     ; Returns a poison value.
    +  %poison4 = load i64* %wideaddr       ; Returns a poison value.
     
    -  %cmp = icmp slt i32 %trap, 0       ; Returns a trap value.
    -  br i1 %cmp, label %true, label %end ; Branch to either destination.
    +  %cmp = icmp slt i32 %poison, 0       ; Returns a poison value.
    +  br i1 %cmp, label %true, label %end  ; Branch to either destination.
     
     true:
    -  volatile store i32 0, i32* @g      ; This is control-dependent on %cmp, so
    -                                     ; it has undefined behavior.
    +  store volatile i32 0, i32* @g        ; This is control-dependent on %cmp, so
    +                                       ; it has undefined behavior.
       br label %end
     
     end:
       %p = phi i32 [ 0, %entry ], [ 1, %true ]
    -                                     ; Both edges into this PHI are
    -                                     ; control-dependent on %cmp, so this
    -                                     ; always results in a trap value.
    +                                       ; Both edges into this PHI are
    +                                       ; control-dependent on %cmp, so this
    +                                       ; always results in a poison value.
     
    -  volatile store i32 0, i32* @g      ; This would depend on the store in %true
    -                                     ; if %cmp is true, or the store in %entry
    -                                     ; otherwise, so this is undefined behavior.
    +  store volatile i32 0, i32* @g        ; This would depend on the store in %true
    +                                       ; if %cmp is true, or the store in %entry
    +                                       ; otherwise, so this is undefined behavior.
     
       br i1 %cmp, label %second_true, label %second_end
    -                                     ; The same branch again, but this time the
    -                                     ; true block doesn't have side effects.
    +                                       ; The same branch again, but this time the
    +                                       ; true block doesn't have side effects.
     
     second_true:
       ; No side effects!
       ret void
     
     second_end:
    -  volatile store i32 0, i32* @g      ; This time, the instruction always depends
    -                                     ; on the store in %end. Also, it is
    -                                     ; control-equivalent to %end, so this is
    -                                     ; well-defined (again, ignoring earlier
    -                                     ; undefined behavior in this example).
    +  store volatile i32 0, i32* @g        ; This time, the instruction always depends
    +                                       ; on the store in %end. Also, it is
    +                                       ; control-equivalent to %end, so this is
    +                                       ; well-defined (ignoring earlier undefined
    +                                       ; behavior in this example).
     
    @@ -2726,7 +2781,7 @@ second_end: make it fit in TYPE.
    inttoptr (CST to TYPE)
    -
    Convert a integer constant to a pointer constant. TYPE must be a pointer +
    Convert an integer constant to a pointer constant. TYPE must be a pointer type. CST must be of integer type. The CST value is zero extended, truncated, or unchanged to make it fit in a pointer size. This one is really dangerous!
    @@ -2800,7 +2855,7 @@ second_end:

    LLVM supports inline assembler expressions (as opposed - to Module-Level Inline Assembly) through the use of + to Module-Level Inline Assembly) through the use of a special value. This value represents the inline assembler as a string (containing the instructions to emit), a list of operand constraints (stored as a string), a flag that indicates whether or not the inline asm @@ -2813,8 +2868,9 @@ 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:

    + a call or an + invoke instruction. + Thus, typically we have:

     %X = call i32 asm "bswap $0", "=r,r"(i32 %Y)
    @@ -2839,26 +2895,40 @@ call void asm sideeffect "eieio", ""()
     call void asm alignstack "eieio", ""()
     
    -

    If both keywords appear the 'sideeffect' keyword must come - first.

    +

    Inline asms also support using non-standard assembly dialects. The assumed + dialect is ATT. When the 'inteldialect' keyword is present, the + inline asm is using the Intel dialect. Currently, ATT and Intel are the + only supported dialects. An example is:

    + +
    +call void asm inteldialect "eieio", ""()
    +
    + +

    If multiple keywords appear the 'sideeffect' keyword must come + first, the 'alignstack' keyword second and the + 'inteldialect' keyword last.

    + +

    -Inline Asm Metadata + Inline Asm Metadata

    -

    The call instructions that wrap inline asm nodes may have a "!srcloc" MDNode - attached to it that contains a list of constant integers. If present, the - code generator will use the integer as the location cookie value when report - errors through the LLVMContext error reporting mechanisms. This allows a - front-end to correlate backend errors that occur with inline asm back to the - source code that produced it. For example:

    +

    The call instructions that wrap inline asm nodes may have a + "!srcloc" MDNode attached to it that contains a list of constant + integers. If present, the code generator will use the integer as the + location cookie value when report errors through the LLVMContext + error reporting mechanisms. This allows a front-end to correlate backend + errors that occur with inline asm back to the source code that produced it. + For example:

     call void asm sideeffect "something bad", ""(), !srcloc !42
    @@ -2867,7 +2937,7 @@ call void asm sideeffect "something bad", ""(), !srcloc !42
     

    It is up to the front-end to make sense of the magic numbers it places in the - IR. If the MDNode contains multiple constants, the code generator will use + IR. If the MDNode contains multiple constants, the code generator will use the one that corresponds to the line of the asm that the error occurs on.

    @@ -2889,20 +2959,33 @@ call void asm sideeffect "something bad", ""(), !srcloc !42 preceding exclamation point ('!').

    A metadata string is a string surrounded by double quotes. It can contain - any character by escaping non-printable characters with "\xx" where "xx" is - the two digit hex code. For example: "!"test\00"".

    + any character by escaping non-printable characters with "\xx" where + "xx" is the two digit hex code. For example: + "!"test\00"".

    Metadata nodes are represented with notation similar to structure constants (a comma separated list of elements, surrounded by braces and preceded by an - exclamation point). For example: "!{ metadata !"test\00", i32 - 10}". Metadata nodes can have any values as their operand.

    + exclamation point). Metadata nodes can have any values as their operand. For + example:

    + +
    +
    +!{ metadata !"test\00", i32 10}
    +
    +

    A named metadata is a collection of metadata nodes, which can be looked up in the module symbol table. For - example: "!foo = metadata !{!4, !3}". + example:

    + +
    +
    +!foo =  metadata !{!4, !3}
    +
    +

    Metadata can be used as function arguments. Here llvm.dbg.value - function is using two metadata arguments.

    + function is using two metadata arguments:

    @@ -2911,7 +2994,8 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
     

    Metadata can be attached with an instruction. Here metadata !21 is - attached with add instruction using !dbg identifier.

    + attached to the add instruction using the !dbg + identifier:

    @@ -2922,6 +3006,7 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
     

    More information about specific metadata nodes recognized by the optimizers and code generator is found below.

    +

    'tbaa' Metadata

    @@ -2966,35 +3051,318 @@ call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
    +

    - 'fpaccuracy' Metadata + 'tbaa.struct' Metadata +

    + +
    + +

    The llvm.memcpy is often used to implement +aggregate assignment operations in C and similar languages, however it is +defined to copy a contiguous region of memory, which is more than strictly +necessary for aggregate types which contain holes due to padding. Also, it +doesn't contain any TBAA information about the fields of the aggregate.

    + +

    !tbaa.struct metadata can describe which memory subregions in a memcpy +are padding and what the TBAA tags of the struct are.

    + +

    The current metadata format is very simple. !tbaa.struct metadata nodes + are a list of operands which are in conceptual groups of three. For each + group of three, the first operand gives the byte offset of a field in bytes, + the second gives its size in bytes, and the third gives its + tbaa tag. e.g.:

    + +
    +
    +!4 = metadata !{ i64 0, i64 4, metadata !1, i64 8, i64 4, metadata !2 }
    +
    +
    + +

    This describes a struct with two fields. The first is at offset 0 bytes + with size 4 bytes, and has tbaa tag !1. The second is at offset 8 bytes + and has size 4 bytes and has tbaa tag !2.

    + +

    Note that the fields need not be contiguous. In this example, there is a + 4 byte gap between the two fields. This gap represents padding which + does not carry useful data and need not be preserved.

    + +
    + + +

    + 'fpmath' Metadata

    -

    fpaccuracy metadata may be attached to any instruction of floating - point type. It expresses the maximum relative error of the result of - that instruction, in ULPs. ULP is defined as follows:

    +

    fpmath metadata may be attached to any instruction of floating point + type. It can be used to express the maximum acceptable error in the result of + that instruction, in ULPs, thus potentially allowing the compiler to use a + more efficient but less accurate method of computing it. ULP is defined as + follows:

    + +
    + +

    If x is a real number that lies between two finite consecutive + floating-point numbers a and b, without being equal to one + of them, then ulp(x) = |b - a|, otherwise ulp(x) is the + distance between the two non-equal finite floating-point numbers nearest + x. Moreover, ulp(NaN) is NaN.

    + +
    + +

    The metadata node shall consist of a single positive floating point number + representing the maximum relative error, for example:

    + +
    +
    +!0 = metadata !{ float 2.5 } ; maximum acceptable inaccuracy is 2.5 ULPs
    +
    +
    + +
    -

    -If x is a real number that lies between two finite consecutive floating-point -numbers a and b, without being equal to one of them, then ulp(x) = |b - a|, -otherwise ulp(x) is the distance between the two non-equal finite -floating-point numbers nearest x. Moreover, ulp(NaN) is NaN. -

    + +

    + 'range' Metadata +

    -

    The maximum relative error may be any rational number. The metadata node - shall consist of a pair of unsigned integers respectively representing - the numerator and denominator. For example, 2.5 ULP:

    +
    +

    range metadata may be attached only to loads of integer types. It + expresses the possible ranges the loaded value is in. The ranges are + represented with a flattened list of integers. The loaded value is known to + be in the union of the ranges defined by each consecutive pair. Each pair + has the following properties:

    + +

    In addition, the pairs must be in signed order of the lower bound and + they must be non-contiguous.

    +

    Examples:

    -!0 = metadata !{ i32 5, i32 2 }
    +  %a = load i8* %x, align 1, !range !0 ; Can only be 0 or 1
    +  %b = load i8* %y, align 1, !range !1 ; Can only be 255 (-1), 0 or 1
    +  %c = load i8* %z, align 1, !range !2 ; Can only be 0, 1, 3, 4 or 5
    +  %d = load i8* %z, align 1, !range !3 ; Can only be -2, -1, 3, 4 or 5
    +...
    +!0 = metadata !{ i8 0, i8 2 }
    +!1 = metadata !{ i8 255, i8 2 }
    +!2 = metadata !{ i8 0, i8 2, i8 3, i8 6 }
    +!3 = metadata !{ i8 -2, i8 0, i8 3, i8 6 }
     
    +
    +
    + +

    + Module Flags Metadata +

    + + +
    + +

    Information about the module as a whole is difficult to convey to LLVM's + subsystems. The LLVM IR isn't sufficient to transmit this + information. The llvm.module.flags named metadata exists in order to + facilitate this. These flags are in the form of key / value pairs — + much like a dictionary — making it easy for any subsystem who cares + about a flag to look it up.

    + +

    The llvm.module.flags metadata contains a list of metadata + triplets. Each triplet has the following form:

    + + + +

    When two (or more) modules are merged together, the resulting + llvm.module.flags metadata is the union of the + modules' llvm.module.flags metadata. The only exception being a flag + with the Override behavior, which may override another flag's value + (see below).

    + +

    The following behaviors are supported:

    + + + + + + + + + + + + + + + + + + + + + + + + +
    ValueBehavior
    1 +
    +
    Error
    +
    Emits an error if two values disagree. It is an error to have an ID + with both an Error and a Warning behavior.
    +
    +
    2 +
    +
    Warning
    +
    Emits a warning if two values disagree.
    +
    +
    3 +
    +
    Require
    +
    Emits an error when the specified value is not present or doesn't + have the specified value. It is an error for two (or more) + llvm.module.flags with the same ID to have the Require + behavior but different values. There may be multiple Require flags + per ID.
    +
    +
    4 +
    +
    Override
    +
    Uses the specified value if the two values disagree. It is an + error for two (or more) llvm.module.flags with the same + ID to have the Override behavior but different values.
    +
    +
    + +

    An example of module flags:

    + +
    +!0 = metadata !{ i32 1, metadata !"foo", i32 1 }
    +!1 = metadata !{ i32 4, metadata !"bar", i32 37 }
    +!2 = metadata !{ i32 2, metadata !"qux", i32 42 }
    +!3 = metadata !{ i32 3, metadata !"qux",
    +  metadata !{
    +    metadata !"foo", i32 1
    +  }
    +}
    +!llvm.module.flags = !{ !0, !1, !2, !3 }
    +
    + + + + + +

    +Objective-C Garbage Collection Module Flags Metadata +

    + +
    + +

    On the Mach-O platform, Objective-C stores metadata about garbage collection + in a special section called "image info". The metadata consists of a version + number and a bitmask specifying what types of garbage collection are + supported (if any) by the file. If two or more modules are linked together + their garbage collection metadata needs to be merged rather than appended + together.

    + +

    The Objective-C garbage collection module flags metadata consists of the + following key-value pairs:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KeyValue
    Objective-C Version[Required] — The Objective-C ABI + version. Valid values are 1 and 2.
    Objective-C Image Info Version[Required] — The version of the image info + section. Currently always 0.
    Objective-C Image Info Section[Required] — The section to place the + metadata. Valid values are "__OBJC, __image_info, regular" for + Objective-C ABI version 1, and "__DATA,__objc_imageinfo, regular, + no_dead_strip" for Objective-C ABI version 2.
    Objective-C Garbage Collection[Required] — Specifies whether garbage + collection is supported or not. Valid values are 0, for no garbage + collection, and 2, for garbage collection supported.
    Objective-C GC Only[Optional] — Specifies that only garbage + collection is supported. If present, its value must be 6. This flag + requires that the Objective-C Garbage Collection flag have the + value 2.
    + +

    Some important flag interactions:

    + + +
    @@ -3147,7 +3515,6 @@ cast formed of bitcast or getelementptr. For example, a legal use of it is:

    'switch', 'indirectbr', 'invoke', - 'unwind', 'resume', and 'unreachable'.

    @@ -3367,15 +3734,15 @@ IfUnequal: 'normal' label or the 'exception' label. If the callee function returns with the "ret" instruction, control flow will return to the "normal" label. If the callee (or any - indirect callees) returns with the "unwind" - instruction, control is interrupted and continued at the dynamically nearest - "exception" label.

    + indirect callees) returns via the "resume" + instruction or other exception handling mechanism, control is interrupted and + continued at the dynamically nearest "exception" label.

    The 'exception' label is a landing pad for the exception. As such, 'exception' label is required to have the "landingpad" instruction, which contains - the information about about the behavior of the program after unwinding + the information about the behavior of the program after unwinding happens, as its first non-PHI instruction. The restrictions on the "landingpad" instruction's tightly couples it to the "invoke" instruction, so that the important information contained @@ -3411,8 +3778,9 @@ IfUnequal:

  • 'normal label': the label reached when the called function executes a 'ret' instruction.
  • -
  • 'exception label': the label reached when a callee returns with - the unwind instruction.
  • +
  • 'exception label': the label reached when a callee returns via + the resume instruction or other exception + handling mechanism.
  • The optional function attributes list. Only 'noreturn', 'nounwind', 'readonly' and @@ -3435,9 +3803,6 @@ IfUnequal: block to the "normal" label. If the callee unwinds then no return value is available.

    -

    Note that the code generator does not yet completely support unwind, and -that the invoke/unwind semantics are likely to change in future versions.

    -
    Example:
       %retval = invoke i32 @Test(i32 15) to label %Continue
    @@ -3446,38 +3811,6 @@ that the invoke/unwind semantics are likely to change in future versions.

    unwind label %TestCleanup ; {i32}:retval set
    - - - - -

    - 'unwind' Instruction -

    - -
    - -
    Syntax:
    -
    -  unwind
    -
    - -
    Overview:
    -

    The 'unwind' instruction unwinds the stack, continuing control flow - at the first callee in the dynamic call stack which used - an invoke instruction to perform the call. - This is primarily used to implement exception handling.

    - -
    Semantics:
    -

    The 'unwind' instruction causes execution of the current function to - immediately halt. The dynamic call stack is then searched for the - first invoke instruction on the call stack. - Once found, execution continues at the "exceptional" destination block - specified by the invoke instruction. If there is no invoke - instruction in the dynamic call chain, undefined behavior results.

    - -

    Note that the code generator does not yet completely support unwind, and -that the invoke/unwind semantics are likely to change in future versions.

    -
    @@ -3590,7 +3923,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    nuw and nsw stand for "No Unsigned Wrap" and "No Signed Wrap", respectively. If the nuw and/or nsw keywords are present, the result value of the add - is a trap value if unsigned and/or signed overflow, + is a poison value if unsigned and/or signed overflow, respectively, occurs.

    Example:
    @@ -3671,7 +4004,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    nuw and nsw stand for "No Unsigned Wrap" and "No Signed Wrap", respectively. If the nuw and/or nsw keywords are present, the result value of the sub - is a trap value if unsigned and/or signed overflow, + is a poison value if unsigned and/or signed overflow, respectively, occurs.

    Example:
    @@ -3758,7 +4091,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    nuw and nsw stand for "No Unsigned Wrap" and "No Signed Wrap", respectively. If the nuw and/or nsw keywords are present, the result value of the mul - is a trap value if unsigned and/or signed overflow, + is a poison value if unsigned and/or signed overflow, respectively, occurs.

    Example:
    @@ -3828,7 +4161,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    Division by zero leads to undefined behavior.

    If the exact keyword is present, the result value of the - udiv is a trap value if %op1 is not a + udiv is a poison value if %op1 is not a multiple of %op2 (as such, "((a udiv exact b) mul b) == a").

    @@ -3872,7 +4205,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    a 32-bit division of -2147483648 by -1.

    If the exact keyword is present, the result value of the - sdiv is a trap value if the result would + sdiv is a poison value if the result would be rounded.

    Example:
    @@ -4081,9 +4414,9 @@ that the invoke/unwind semantics are likely to change in future versions.

    shift amount in op2.

    If the nuw keyword is present, then the shift produces a - trap value if it shifts out any non-zero bits. If + poison value if it shifts out any non-zero bits. If the nsw keyword is present, then the shift produces a - trap value if it shifts out any bits that disagree + poison value if it shifts out any bits that disagree with the resultant sign bit. As such, NUW/NSW have the same semantics as they would if the shift were expressed as a mul instruction with the same nsw/nuw bits in (mul %op1, (shl 1, %op2)).

    @@ -4130,7 +4463,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    shift amount in op2.

    If the exact keyword is present, the result value of the - lshr is a trap value if any of the bits + lshr is a poison value if any of the bits shifted out are non-zero.

    @@ -4178,7 +4511,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    the corresponding shift amount in op2.

    If the exact keyword is present, the result value of the - ashr is a trap value if any of the bits + ashr is a poison value if any of the bits shifted out are non-zero.

    Example:
    @@ -4220,9 +4553,9 @@ that the invoke/unwind semantics are likely to change in future versions.

    - - - + + + @@ -4281,9 +4614,9 @@ that the invoke/unwind semantics are likely to change in future versions.

    In0In1OutIn0In1Out
    0
    - - - + + + @@ -4345,9 +4678,9 @@ that the invoke/unwind semantics are likely to change in future versions.

    In0In1OutIn0In1Out
    0
    - - - + + + @@ -4489,7 +4822,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    Arguments:

    The first two operands of a 'shufflevector' instruction are vectors - with types that match each other. The third argument is a shuffle mask whose + with the same type. The third argument is a shuffle mask whose element type is always 'i32'. The result of the instruction is a vector whose length is the same as the shuffle mask and whose element type is the same as the element type of the first two operands.

    @@ -4664,8 +4997,12 @@ that the invoke/unwind semantics are likely to change in future versions.

    'alloca' instruction is commonly used to represent automatic variables that must have an address available. When the function returns (either with the ret - or unwind instructions), the memory is - reclaimed. Allocating zero bytes is legal, but the result is undefined.

    + or resume instructions), the memory is + reclaimed. Allocating zero bytes is legal, but the result is undefined. + The order in which memory is allocated (ie., which way the stack grows) is + not specified.

    + +

    Example:
    @@ -4686,7 +5023,7 @@ that the invoke/unwind semantics are likely to change in future versions.

    Syntax:
    -  <result> = load [volatile] <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>]
    +  <result> = load [volatile] <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>][, !invariant.load !<index>]
       <result> = load atomic [volatile] <ty>* <pointer> [singlethread] <ordering>, align <alignment>
       !<index> = !{ i32 1 }
     
    @@ -4731,6 +5068,14 @@ that the invoke/unwind semantics are likely to change in future versions.

    The code generator may select special instructions to save cache bandwidth, such as the MOVNT instruction on x86.

    +

    The optional !invariant.load metadata must reference a single + metatadata name <index> corresponding to a metadata node with no + entries. The existence of the !invariant.load metatadata on the + instruction tells the optimizer and code generator that this load address + points to memory which does not change value during program execution. + The optimizer may then move this load around, for example, by hoisting it + out of loops using loop invariant code motion.

    +
    Semantics:

    The location of memory pointed to is loaded. If the value being loaded is of scalar type then the number of bytes read does not exceed the minimum number @@ -4758,8 +5103,8 @@ that the invoke/unwind semantics are likely to change in future versions.

    Syntax:
    -  store [volatile] <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>]                   ; yields {void}
    -  store atomic [volatile] <ty> <value>, <ty>* <pointer> [singlethread] <ordering>, align <alignment>             ; yields {void}
    +  store [volatile] <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>]        ; yields {void}
    +  store atomic [volatile] <ty> <value>, <ty>* <pointer> [singlethread] <ordering>, align <alignment>  ; yields {void}
     
    Overview:
    @@ -4888,7 +5233,7 @@ thread. (This is useful for interacting with signal handlers.)

    Syntax:
    -  cmpxchg [volatile] <ty>* <pointer>, <ty> <cmp>, <ty> <new> [singlethread] <ordering>                   ; yields {ty}
    +  cmpxchg [volatile] <ty>* <pointer>, <ty> <cmp>, <ty> <new> [singlethread] <ordering>  ; yields {ty}
     
    Overview:
    @@ -4946,13 +5291,13 @@ FIXME: Is a weaker ordering constraint on failure helpful in practice?
    Example:
     entry:
    -  %orig = atomic load i32* %ptr unordered                       ; yields {i32}
    +  %orig = atomic load i32* %ptr unordered                   ; yields {i32}
       br label %loop
     
     loop:
       %cmp = phi i32 [ %orig, %entry ], [%old, %loop]
       %squared = mul i32 %cmp, %cmp
    -  %old = cmpxchg i32* %ptr, i32 %cmp, i32 %squared                       ; yields {i32}
    +  %old = cmpxchg i32* %ptr, i32 %cmp, i32 %squared          ; yields {i32}
       %success = icmp eq i32 %cmp, %old
       br i1 %success, label %done, label %loop
     
    @@ -5044,6 +5389,7 @@ specified by the operation argument:

       <result> = getelementptr <pty>* <ptrval>{, <ty> <idx>}*
       <result> = getelementptr inbounds <pty>* <ptrval>{, <ty> <idx>}*
    +  <result> = getelementptr <ptr vector> ptrval, <vector index type> idx 
     
    Overview:
    @@ -5052,7 +5398,8 @@ specified by the operation argument:

    It performs address calculation only and does not access memory.

    Arguments:
    -

    The first argument is always a pointer, and forms the basis of the +

    The first argument is always a pointer or a vector of pointers, + and forms the basis of the calculation. The remaining arguments are indices that indicate which of the elements of the aggregate object are indexed. The interpretation of each index is dependent on the type being indexed into. The first index always @@ -5090,54 +5437,57 @@ int *foo(struct ST *s) { }

    -

    The LLVM code generated by the GCC frontend is:

    +

    The LLVM code generated by Clang is:

    -%RT = type { i8 , [10 x [20 x i32]], i8  }
    -%ST = type { i32, double, %RT }
    +%struct.RT = type { i8, [10 x [20 x i32]], i8 }
    +%struct.ST = type { i32, double, %struct.RT }
     
    -define i32* @foo(%ST* %s) {
    +define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
     entry:
    -  %reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13
    -  ret i32* %reg
    +  %arrayidx = getelementptr inbounds %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
    +  ret i32* %arrayidx
     }
     
    Semantics:
    -

    In the example above, the first index is indexing into the '%ST*' - type, which is a pointer, yielding a '%ST' = '{ i32, double, %RT - }' type, a structure. The second index indexes into the third element - of the structure, yielding a '%RT' = '{ i8 , [10 x [20 x i32]], - i8 }' type, another structure. The third index indexes into the second - element of the structure, yielding a '[10 x [20 x i32]]' type, an - array. The two dimensions of the array are subscripted into, yielding an - 'i32' type. The 'getelementptr' instruction returns a - pointer to this element, thus computing a value of 'i32*' type.

    +

    In the example above, the first index is indexing into the + '%struct.ST*' type, which is a pointer, yielding a + '%struct.ST' = '{ i32, double, %struct.RT }' type, a + structure. The second index indexes into the third element of the structure, + yielding a '%struct.RT' = '{ i8 , [10 x [20 x i32]], i8 }' + type, another structure. The third index indexes into the second element of + the structure, yielding a '[10 x [20 x i32]]' type, an array. The + two dimensions of the array are subscripted into, yielding an 'i32' + type. The 'getelementptr' instruction returns a pointer to this + element, thus computing a value of 'i32*' type.

    Note that it is perfectly legal to index partially through a structure, returning a pointer to an inner element. Because of this, 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
    -    %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
    -  }
    +
    +define i32* @foo(%struct.ST* %s) {
    +  %t1 = getelementptr %struct.ST* %s, i32 1                 ; yields %struct.ST*:%t1
    +  %t2 = getelementptr %struct.ST* %t1, i32 0, i32 2         ; yields %struct.RT*:%t2
    +  %t3 = getelementptr %struct.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
    +}
     

    If the inbounds keyword is present, the result value of the - getelementptr is a trap value if the + getelementptr is a poison value if the base pointer is not an in bounds address of an allocated object, or if any of the addresses that would be formed by successive addition of the offsets implied by the indices to the base address with infinitely precise signed arithmetic are not an in bounds address of that allocated object. The in bounds addresses for an allocated object are all the addresses that point into the object, plus the address one - byte past the end.

    + byte past the end. + In cases where the base is a vector of pointers the inbounds keyword + applies to each of the computations element-wise.

    If the inbounds keyword is not present, the offsets are added to the base address with silently-wrapping two's complement arithmetic. If the @@ -5164,6 +5514,13 @@ entry: %iptr = getelementptr [10 x i32]* @arr, i16 0, i16 0

    +

    In cases where the pointer argument is a vector of pointers, only a + single index may be used, and the number of vector elements has to be + the same. For example:

    +
    + %A = getelementptr <4 x i8*> %ptrs, <4 x i64> %offsets,
    +
    + @@ -5536,13 +5893,16 @@ entry:
    Overview:
    -

    The 'ptrtoint' instruction converts the pointer value to - the integer type ty2.

    +

    The 'ptrtoint' instruction converts the pointer or a vector of + pointers value to + the integer (or vector of integers) type ty2.

    Arguments:

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

    + must be a a value of type pointer or a vector of + pointers, and a type to cast it to + ty2, which must be an integer or a vector + of integers type.

    Semantics:

    The 'ptrtoint' instruction converts value to integer type @@ -5555,8 +5915,9 @@ entry:

    Example:
    -  %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
    +  %X = ptrtoint i32* %P to i8                         ; yields truncation on 32-bit architecture
    +  %Y = ptrtoint i32* %P to i64                        ; yields zero extension on 32-bit architecture
    +  %Z = ptrtoint <4 x i32*> %P to <4 x i64>; yields vector zero extension for a vector of addresses on 32-bit architecture
     
    @@ -5595,6 +5956,7 @@ entry: %X = inttoptr i32 255 to i32* ; yields zero extension on 64-bit architecture %Y = inttoptr i32 255 to i32* ; yields no-op on 32-bit architecture %Z = inttoptr i64 0 to i32* ; yields truncation on 32-bit architecture + %Z = inttoptr <4 x i32> %G to <4 x i8*>; yields truncation of vector G to four pointers @@ -5629,8 +5991,9 @@ entry:

    The 'bitcast' instruction converts value to type ty2. It is always a no-op cast because no bits change with this conversion. The conversion is done as if the value had been - stored to memory and read back as type ty2. Pointer types may only - be converted to other pointer types with this instruction. To convert + stored to memory and read back as type ty2. + Pointer (or vector of pointers) types may only be converted to other pointer + (or vector of pointers) types with this instruction. To convert pointers to other types, use the inttoptr or ptrtoint instructions first.

    @@ -5638,7 +6001,8 @@ entry:
       %X = bitcast i8 255 to i8              ; yields i8 :-1
       %Y = bitcast i32* %x to sint*          ; yields sint*:%x
    -  %Z = bitcast <2 x int> %V to i64;      ; yields i64: %V
    +  %Z = bitcast <2 x int> %V to i64;        ; yields i64: %V
    +  %Z = bitcast <2 x i32*> %V to <2 x i64*> ; yields <2 x i64*>
     
    @@ -5669,8 +6033,8 @@ entry:
    Overview:

    The 'icmp' instruction returns a boolean value or a vector of - boolean values based on comparison of its two integer, integer vector, or - pointer operands.

    + boolean values based on comparison of its two integer, integer vector, + pointer, or pointer vector operands.

    Arguments:

    The 'icmp' instruction takes three operands. The first operand is @@ -5965,9 +6329,6 @@ Loop: ; Infinite loop that counts from 0 on up... %X = select i1 true, i8 17, i8 42 ; yields i8:17 -

    Note that the code generator does not yet support conditions - with vector type.

    - @@ -6134,8 +6495,8 @@ freestanding environments and non-C-based languages.

    Syntax:
    -  <resultval> = landingpad <somety> personality <type> <pers_fn> <clause>+
    -  <resultval> = landingpad <somety> personality <type> <pers_fn> cleanup <clause>*
    +  <resultval> = landingpad <resultty> personality <type> <pers_fn> <clause>+
    +  <resultval> = landingpad <resultty> personality <type> <pers_fn> cleanup <clause>*
     
       <clause> := catch <type> <value>
       <clause> := filter <array constant type> <array constant>
    @@ -6149,7 +6510,7 @@ freestanding environments and non-C-based languages.

    catch portion of a try/catch sequence. It defines values supplied by the personality function (pers_fn) upon re-entry to the function. The resultval has the - type somety.

    + type resultty.

    Arguments:

    This instruction takes a pers_fn value. This is the personality @@ -6173,7 +6534,11 @@ freestanding environments and non-C-based languages.

    The clauses are applied in order from top to bottom. If two landingpad instructions are merged together through inlining, the - clauses from the calling function are appended to the list of clauses.

    + clauses from the calling function are appended to the list of clauses. + When the call stack is being unwound due to an exception being thrown, the + exception is compared against each clause in turn. If it doesn't + match any of the clauses, and the cleanup flag is not set, then + unwinding continues further up the call stack.

    The landingpad instruction has several restrictions:

    @@ -7194,6 +7559,74 @@ LLVM.

    + +

    + 'llvm.fabs.*' Intrinsic +

    + +
    + +
    Syntax:
    +

    This is an overloaded intrinsic. You can use llvm.fabs on any + floating point or vector of floating point type. Not all targets support all + types however.

    + +
    +  declare float     @llvm.fabs.f32(float  %Val)
    +  declare double    @llvm.fabs.f64(double %Val)
    +  declare x86_fp80  @llvm.fabs.f80(x86_fp80  %Val)
    +  declare fp128     @llvm.fabs.f128(fp128 %Val)
    +  declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128  %Val)
    +
    + +
    Overview:
    +

    The 'llvm.fabs.*' intrinsics return the absolute value of + the operand.

    + +
    Arguments:
    +

    The argument and return value are floating point numbers of the same + type.

    + +
    Semantics:
    +

    This function returns the same values as the libm fabs functions + would, and handles error conditions in the same way.

    + +
    + + +

    + 'llvm.floor.*' Intrinsic +

    + +
    + +
    Syntax:
    +

    This is an overloaded intrinsic. You can use llvm.floor on any + floating point or vector of floating point type. Not all targets support all + types however.

    + +
    +  declare float     @llvm.floor.f32(float  %Val)
    +  declare double    @llvm.floor.f64(double %Val)
    +  declare x86_fp80  @llvm.floor.f80(x86_fp80  %Val)
    +  declare fp128     @llvm.floor.f128(fp128 %Val)
    +  declare ppc_fp128 @llvm.floor.ppcf128(ppc_fp128  %Val)
    +
    + +
    Overview:
    +

    The 'llvm.floor.*' intrinsics return the floor of + the operand.

    + +
    Arguments:
    +

    The argument and return value are floating point numbers of the same + type.

    + +
    Semantics:
    +

    This function returns the same values as the libm floor functions + would, and handles error conditions in the same way.

    + +
    + @@ -7290,12 +7723,12 @@ LLVM.

    targets support all bit widths or vector types, 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 i256 @llvm.ctlz.i256(i256 <src>)
    -  declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32> <src;gt)
    +  declare i8   @llvm.ctlz.i8  (i8   <src>, i1 <is_zero_undef>)
    +  declare i16  @llvm.ctlz.i16 (i16  <src>, i1 <is_zero_undef>)
    +  declare i32  @llvm.ctlz.i32 (i32  <src>, i1 <is_zero_undef>)
    +  declare i64  @llvm.ctlz.i64 (i64  <src>, i1 <is_zero_undef>)
    +  declare i256 @llvm.ctlz.i256(i256 <src>, i1 <is_zero_undef>)
    +  declase <2 x i32> @llvm.ctlz.v2i32(<2 x i32> <src>, i1 <is_zero_undef>)
     
    Overview:
    @@ -7303,15 +7736,22 @@ LLVM.

    leading zeros in a variable.

    Arguments:
    -

    The only argument is the value to be counted. The argument may be of any - integer type, or any vector type with integer element type. - The return type must match the argument type.

    +

    The first argument is the value to be counted. This argument may be of any + integer type, or a vectory with integer element type. The return type + must match the first argument type.

    + +

    The second argument must be a constant and is a flag to indicate whether the + intrinsic should ensure that a zero as the first argument produces a defined + result. Historically some architectures did not provide a defined result for + zero values as efficiently, and many algorithms are now predicated on + avoiding zero-value inputs.

    Semantics:

    The 'llvm.ctlz' intrinsic counts the leading (most significant) - zeros in a variable, or within each element of the vector if the operation - is of vector type. If the src == 0 then the result is the size in bits of - the type of src. For example, llvm.ctlz(i32 2) = 30.

    + zeros in a variable, or within each element of the vector. + If src == 0 then the result is the size in bits of the type of + src if is_zero_undef == 0 and undef otherwise. + For example, llvm.ctlz(i32 2) = 30.

    @@ -7328,12 +7768,12 @@ LLVM.

    support all bit widths or vector types, 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 i256 @llvm.cttz.i256(i256 <src>)
    -  declase <2 x i32> @llvm.cttz.v2i32(<2 x i32> <src>)
    +  declare i8   @llvm.cttz.i8  (i8   <src>, i1 <is_zero_undef>)
    +  declare i16  @llvm.cttz.i16 (i16  <src>, i1 <is_zero_undef>)
    +  declare i32  @llvm.cttz.i32 (i32  <src>, i1 <is_zero_undef>)
    +  declare i64  @llvm.cttz.i64 (i64  <src>, i1 <is_zero_undef>)
    +  declare i256 @llvm.cttz.i256(i256 <src>, i1 <is_zero_undef>)
    +  declase <2 x i32> @llvm.cttz.v2i32(<2 x i32> <src>, i1 <is_zero_undef>)
     
    Overview:
    @@ -7341,15 +7781,22 @@ LLVM.

    trailing zeros.

    Arguments:
    -

    The only argument is the value to be counted. The argument may be of any - integer type, or a vectory with integer element type.. The return type - must match the argument type.

    +

    The first argument is the value to be counted. This argument may be of any + integer type, or a vectory with integer element type. The return type + must match the first argument type.

    + +

    The second argument must be a constant and is a flag to indicate whether the + intrinsic should ensure that a zero as the first argument produces a defined + result. Historically some architectures did not provide a defined result for + zero values as efficiently, and many algorithms are now predicated on + avoiding zero-value inputs.

    Semantics:

    The 'llvm.cttz' intrinsic counts the trailing (least significant) zeros in a variable, or within each element of a vector. - If the src == 0 then the result is the size in bits of - the type of src. For example, llvm.cttz(2) = 1.

    + If src == 0 then the result is the size in bits of the type of + src if is_zero_undef == 0 and undef otherwise. + For example, llvm.cttz(2) = 1.

    @@ -7654,6 +8101,52 @@ LLVM.

    + +

    + Specialised Arithmetic Intrinsics +

    + + + +

    + 'llvm.fmuladd.*' Intrinsic +

    + +
    + +
    Syntax:
    +
    +  declare float @llvm.fmuladd.f32(float %a, float %b, float %c)
    +  declare double @llvm.fmuladd.f64(double %a, double %b, double %c)
    +
    + +
    Overview:
    +

    The 'llvm.fmuladd.*' intrinsic functions represent multiply-add +expressions that can be fused if the code generator determines that the fused +expression would be legal and efficient.

    + +
    Arguments:
    +

    The 'llvm.fmuladd.*' intrinsics each take three arguments: two +multiplicands, a and b, and an addend c.

    + +
    Semantics:
    +

    The expression:

    +
    +  %0 = call float @llvm.fmuladd.f32(%a, %b, %c)
    +
    +

    is equivalent to the expression a * b + c, except that rounding will not be +performed between the multiplication and addition steps if the code generator +fuses the operations. Fusion is not guaranteed, even if the target platform +supports it. If a fused multiply-add is required the corresponding llvm.fma.* +intrinsic function should be used instead.

    + +
    Examples:
    +
    +  %r2 = call float @llvm.fmuladd.f32(float %a, float %b, float %c) ; yields {float}:r2 = (a * b) + c
    +
    + +
    +

    Half Precision Floating Point Intrinsics @@ -7661,7 +8154,8 @@ LLVM.

    -

    Half precision floating point is a storage-only format. This means that it is +

    For most target platforms, half precision floating point is a storage-only + format. This means that it is a dense encoding (in memory) but does not support computation in the format.

    @@ -8098,7 +8592,7 @@ LLVM.

    Syntax:
    -  declare void @llvm.trap()
    +  declare void @llvm.trap() noreturn nounwind
     
    Overview:
    @@ -8108,9 +8602,33 @@ LLVM.

    None.

    Semantics:
    -

    This intrinsics is lowered to the target dependent trap instruction. If the +

    This intrinsic is lowered to the target dependent trap instruction. If the target does not have a trap instruction, this intrinsic will be lowered to - the call of the abort() function.

    + a call of the abort() function.

    + +
    + + +

    + 'llvm.debugtrap' Intrinsic +

    + +
    + +
    Syntax:
    +
    +  declare void @llvm.debugtrap() nounwind
    +
    + +
    Overview:
    +

    The 'llvm.debugtrap' intrinsic.

    + +
    Arguments:
    +

    None.

    + +
    Semantics:
    +

    This intrinsic is lowered to code which is intended to cause an execution + trap with the intention of requesting the attention of a debugger.

    @@ -8157,8 +8675,8 @@ LLVM.

    Syntax:
    -  declare i32 @llvm.objectsize.i32(i8* <object>, i1 <type>)
    -  declare i64 @llvm.objectsize.i64(i8* <object>, i1 <type>)
    +  declare i32 @llvm.objectsize.i32(i8* <object>, i1 <min>)
    +  declare i64 @llvm.objectsize.i64(i8* <object>, i1 <min>)
     
    Overview:
    @@ -8171,22 +8689,70 @@ LLVM.

    Arguments:

    The llvm.objectsize intrinsic takes two arguments. The first argument is a pointer to or into the object. The second argument - is a boolean 0 or 1. This argument determines whether you want the - maximum (0) or minimum (1) bytes remaining. This needs to be a literal 0 or - 1, variables are not allowed.

    + is a boolean and determines whether llvm.objectsize returns 0 (if + true) or -1 (if false) when the object size is unknown. + The second argument only accepts constants.

    Semantics:
    -

    The llvm.objectsize intrinsic is lowered to either a constant - representing the size of the object concerned, or i32/i64 -1 or 0, - depending on the type argument, if the size cannot be determined at - compile time.

    +

    The llvm.objectsize intrinsic is lowered to a constant representing + the size of the object concerned. If the size cannot be determined at compile + time, llvm.objectsize returns i32/i64 -1 or 0 + (depending on the min argument).

    + +

    + 'llvm.expect' Intrinsic +

    + +
    + +
    Syntax:
    +
    +  declare i32 @llvm.expect.i32(i32 <val>, i32 <expected_val>)
    +  declare i64 @llvm.expect.i64(i64 <val>, i64 <expected_val>)
    +
    + +
    Overview:
    +

    The llvm.expect intrinsic provides information about expected (the + most probable) value of val, which can be used by optimizers.

    + +
    Arguments:
    +

    The llvm.expect intrinsic takes two arguments. The first + argument is a value. The second argument is an expected value, this needs to + be a constant value, variables are not allowed.

    +
    Semantics:
    +

    This intrinsic is lowered to the val.

    +
    + + +

    + 'llvm.donothing' Intrinsic +

    + +
    + +
    Syntax:
    +
    +  declare void @llvm.donothing() nounwind readnone
    +
    + +
    Overview:
    +

    The llvm.donothing intrinsic doesn't perform any operation. It's the +only intrinsic that can be called with an invoke instruction.

    + +
    Arguments:
    +

    None.

    + +
    Semantics:
    +

    This intrinsic does nothing, and it's removed by optimizers and ignored by +codegen.

    +
    In0In1OutIn0In1Out
    0