X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=15f95e2a11c477052022048040e426d6bb0ed6f2;hb=445c89a83c97176179c54bf5fbc344a597f0ed38;hp=88970f971ecad8cb4e3c9cc23e262003e1555c22;hpb=ef56ce18b81ef8d9769ec9620f35a6c6843d1db8;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index 88970f971ec..15f95e2a11c 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -41,6 +41,7 @@
  • Floating Point Types
  • Void Type
  • Label Type
  • +
  • Metadata Type
  • Derived Types @@ -61,10 +62,11 @@
  • Constants
    1. Simple Constants
    2. -
    3. Aggregate Constants
    4. +
    5. Complex Constants
    6. Global Variable and Function Addresses
    7. Undefined Values
    8. Constant Expressions
    9. +
    10. Embedded Metadata
  • Other Values @@ -87,8 +89,11 @@
  • Binary Operations
    1. 'add' Instruction
    2. +
    3. 'fadd' Instruction
    4. 'sub' Instruction
    5. +
    6. 'fsub' Instruction
    7. 'mul' Instruction
    8. +
    9. 'fmul' Instruction
    10. 'udiv' Instruction
    11. 'sdiv' Instruction
    12. 'fdiv' Instruction
    13. @@ -150,8 +155,6 @@
      1. 'icmp' Instruction
      2. 'fcmp' Instruction
      3. -
      4. 'vicmp' Instruction
      5. -
      6. 'vfcmp' Instruction
      7. 'phi' Instruction
      8. 'select' Instruction
      9. 'call' Instruction
      10. @@ -205,8 +208,16 @@
      11. 'llvm.ctpop.*' Intrinsic
      12. 'llvm.ctlz.*' Intrinsic
      13. 'llvm.cttz.*' Intrinsic
      14. -
      15. 'llvm.part.select.*' Intrinsic
      16. -
      17. 'llvm.part.set.*' Intrinsic
      18. +
      + +
    14. Arithmetic with Overflow Intrinsics +
        +
      1. 'llvm.sadd.with.overflow.* Intrinsics
      2. +
      3. 'llvm.uadd.with.overflow.* Intrinsics
      4. +
      5. 'llvm.ssub.with.overflow.* Intrinsics
      6. +
      7. 'llvm.usub.with.overflow.* Intrinsics
      8. +
      9. 'llvm.smul.with.overflow.* Intrinsics
      10. +
      11. 'llvm.umul.with.overflow.* Intrinsics
    15. Debugger intrinsics
    16. @@ -498,6 +509,17 @@ All Global Variables and Functions have one of the following types of linkage: 'static' keyword in C. +
      available_externally: +
      + +
      Globals with "available_externally" linkage are never emitted + into the object file corresponding to the LLVM module. They exist to + allow inlining and other optimizations to take place given knowledge of the + definition of the global, which is known to be somewhere outside the module. + Globals with available_externally linkage are allowed to be discarded + at will, and are otherwise the same as linkonce_odr. This linkage + type is only allowed on definitions, not declarations.
      +
      linkonce:
      Globals with "linkonce" linkage are merged with other globals of @@ -535,11 +557,23 @@ All Global Variables and Functions have one of the following types of linkage:
      extern_weak:
      +
      The semantics of this linkage follow the ELF object file model: the symbol is weak until linked, if not linked, the symbol becomes null instead of being an undefined reference.
      +
      linkonce_odr:
      +
      weak_odr:
      +
      Some languages allow differing globals to be merged, such as two + functions with different semantics. Other languages, such as C++, + ensure that only equivalent globals are ever merged (the "one definition + rule" - "ODR"). Such languages can use the linkonce_odr + and weak_odr linkage types to indicate that the global will only + be merged with equivalent globals. These linkage types are otherwise the + same as their non-odr versions. +
      +
      externally visible:
      If none of the above identifiers are used, the global is externally @@ -581,10 +615,10 @@ 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", dllimport, +to have any linkage type other than "externally visible", dllimport or extern_weak.

      -

      Aliases can have only external, internal and weak -linkages.

      +

      Aliases can have only external, internal, weak +or weak_odr linkages.

      @@ -884,7 +918,7 @@ define [linkage] [visibility]
      -declare i32 @printf(i8* noalias , ...)
      +declare i32 @printf(i8* noalias nocapture, ...)
       declare i32 @atoi(i8 zeroext)
       declare signext i8 @returns_signed_char()
       
      @@ -922,7 +956,10 @@ declare signext i8 @returns_signed_char() belong to the caller not the callee (for example, readonly functions should not write to byval parameters). This is not a valid attribute for return - values.
      + values. The byval attribute also supports specifying an alignment with the + align attribute. This has a target-specific effect on the code generator + that usually indicates a desired alignment for the synthesized stack + slot.
      sret
      This indicates that the pointer parameter specifies the address of a @@ -1024,12 +1061,14 @@ unwind or exceptional control flow. If the function does unwind, its runtime behavior is undefined.
      readnone
      -
      This attribute indicates that the function computes its result (or the -exception it throws) based strictly on its arguments, without dereferencing any +
      This attribute indicates that the function computes its result (or decides to +unwind an exception) based strictly on its arguments, without dereferencing any pointer arguments or otherwise accessing any mutable state (e.g. memory, control registers, etc) visible to caller functions. It does not write through any pointer arguments (including byval arguments) and -never changes any state visible to callers.
      +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.
      readonly
      This attribute indicates that the function does not write through any @@ -1037,8 +1076,9 @@ pointer arguments (including byval arguments) or otherwise modify any state (e.g. memory, control registers, etc) visible to caller functions. It may dereference pointer arguments and read state that may be set in the caller. A readonly function always returns the same value (or -throws the same exception) when called with the same set of arguments and global -state.
      +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.
      ssp
      This attribute indicates that the function should emit a stack smashing @@ -1047,19 +1087,28 @@ stack before the local variables that's checked upon return from the function to see if it has been overwritten. A heuristic is used to determine if a function needs stack protectors or not. -

      If a function that has an ssp attribute is inlined into a function +

      If a function that has an ssp attribute is inlined into a function that doesn't have an ssp attribute, then the resulting function will -have an ssp attribute.

      +have an ssp attribute.
      sspreq
      This attribute indicates that the function should always emit a stack smashing protector. This overrides the ssp function attribute. -

      If a function that has an sspreq attribute is inlined into a +If a function that has an sspreq attribute is inlined into a function that doesn't have an sspreq attribute or which has an ssp attribute, then the resulting function will have -an sspreq attribute.

      +an sspreq attribute. + +
      noredzone
      +
      This attribute indicates that the code generator should not use a +red zone, even if the target-specific ABI normally permits it. +
      + +
      noimplicitfloat
      +
      This attributes disables implicit floating point instructions.
      + @@ -1133,6 +1182,9 @@ aspect of the data layout. The specifications accepted are as follows:

      asize:abi:pref
      This specifies the alignment for an aggregate type of a given bit size.
      +
      ssize:abi:pref
      +
      This specifies the alignment for a stack object 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 @@ -1152,6 +1204,7 @@ are given in this list:

    17. v64:64:64 - 64-bit vector is 64-bit aligned
    18. v128:128:128 - 128-bit vector is 128-bit aligned
    19. a0:0:1 - aggregates are 8-bit aligned
    20. +
    21. s0:64:64 - stack objects are 64-bit aligned
    22. When LLVM is determining the alignment for a given type, it uses the following rules:

      @@ -1214,14 +1267,16 @@ classifications:

      vector, structure, array, - label. + label, + metadata. primitive label, void, - floating point. + floating point, + metadata. derived @@ -1297,6 +1352,22 @@ system.

      + + + +
      +
      Overview:
      +

      The metadata type represents embedded metadata. The only derived type that +may contain metadata is metadata* or a function type that returns or +takes metadata typed parameters, but not pointer to metadata types.

      + +
      Syntax:
      + +
      +  metadata
      +
      +
      + @@ -1331,18 +1402,18 @@ value.

      Examples:
      - - - - - - - - - - + + + + + + + + + + + -
      i1a single-bit integer.
      i32a 32-bit integer.
      i1942652a really big integer of over 1 million bits.
      i1a single-bit integer.
      i32a 32-bit integer.
      i1942652a really big integer of over 1 million bits.

      Note that the code generator does not yet support large integer types @@ -1549,6 +1620,10 @@ reference to another object, which must live in memory. Pointer types may have an optional address space attribute defining the target-specific numbered address space where the pointed-to object resides. The default address space is zero.

      + +

      Note that LLVM does not permit pointers to void (void*) nor does +it permit pointers to labels (label*). Use i8* instead.

      +
      Syntax:
        <type> *
      Examples:
      @@ -1660,7 +1735,7 @@ pointer to any of the types it is lexically a member of. Example of up references (with their equivalent as named type declarations) include:

      -   { \2 * }                %x = type { %t* }
      +   { \2 * }                %x = type { %x* }
          { \2 }*                 %y = type { %y }*
          \1*                     %z = type %z*
       
      @@ -1743,25 +1818,42 @@ them all and their syntax.

      -

      The one non-intuitive notation for constants is the optional hexadecimal form +

      The one non-intuitive notation for constants is the hexadecimal form of floating point constants. For example, the form 'double 0x432ff973cafa8000' is equivalent to (but harder to read than) 'double 4.5e+15'. The only time hexadecimal floating point constants are required (and the only time that they are generated by the disassembler) is when a floating point constant must be emitted but it cannot be represented as a -decimal floating point number. For example, NaN's, infinities, and other +decimal floating point number in a reasonable number of digits. For example, +NaN's, infinities, and other special values are 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 +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 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).

      -
      Aggregate Constants +
      -

      Aggregate constants arise from aggregation of simple constants -and smaller aggregate constants.

      +

      Complex constants are a (potentially recursive) combination of simple +constants and smaller complex constants.

      Structure constants
      @@ -1801,6 +1893,15 @@ and smaller aggregate constants.

      large arrays) and is always exactly equivalent to using explicit zero initializers. + +
      Metadata node
      + +
      A metadata node is a structure-like constant with + metadata type. For example: + "metadata !{ i32 0, metadata !"test" }". Unlike other constants + that are meant to be interpreted as part of the instruction stream, metadata + is a place to attach additional information such as debug info. +
      @@ -1915,14 +2016,9 @@ following is the syntax for constant expressions:

      really dangerous!
      bitcast ( CST to TYPE )
      -
      Convert a constant, CST, to another TYPE. The size of CST and TYPE must be - 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 - 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. It is not valid - to bitcast to or from an aggregate type. -
      +
      Convert a constant, CST, to another TYPE. The constraints of the operands + are the same as those for the bitcast + instruction.
      getelementptr ( CSTPTR, IDX0, IDX1, ... )
      @@ -1942,12 +2038,6 @@ following is the syntax for constant expressions:

      fcmp COND ( VAL1, VAL2 )
      Performs the fcmp operation on constants.
      -
      vicmp COND ( VAL1, VAL2 )
      -
      Performs the vicmp operation on constants.
      - -
      vfcmp COND ( VAL1, VAL2 )
      -
      Performs the vfcmp operation on constants.
      -
      extractelement ( VAL, IDX )
      Perform the extractelement @@ -1974,6 +2064,39 @@ following is the syntax for constant expressions:

      + + + +
      + +

      Embedded metadata provides a way to attach arbitrary data to the +instruction stream without affecting the behaviour of the program. There are +two metadata primitives, strings and nodes. All metadata has the +metadata type and is identified in syntax by a 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"". +

      + +

      Metadata nodes are represented with notation similar to structure constants +(a comma separated list of elements, surrounded by braces and preceeded by an +exclamation point). For example: "!{ metadata !"test\00", i32 10}". +

      + +

      A metadata node will attempt to track changes to the values it holds. In +the event that a value is deleted, it will be replaced with a typeless +"null", such as "metadata !{null, i32 10}".

      + +

      Optimizations may rely on metadata to provide additional information about +the program that isn't available in the instructions, or that isn't easily +computable. Similarly, the code generator may expect a certain metadata format +to be used to express debugging information.

      +
      + @@ -2113,7 +2236,7 @@ return value.

         ret i32 5                       ; Return an integer value of 5
         ret void                        ; Return from a void function
      -  ret { i32, i8 } { i32 4, i8 2 } ; Return an aggregate of values 4 and 2
      +  ret { i32, i8 } { i32 4, i8 2 } ; Return a struct of values 4 and 2
       

      Note that the code generator does not yet fully support large @@ -2147,7 +2270,7 @@ 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 i1 %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
      @@ -2286,6 +2409,11 @@ cleanup is performed in the case of either a longjmp or a thrown exception. Additionally, this is important for implementation of 'catch' clauses in high-level languages that support them.

      +

      For the purposes of the SSA form, the definition of the value +returned by the 'invoke' instruction is deemed to occur on +the edge from the current block to the "normal" label. If the callee +unwinds then no return value is available.

      +
      Example:
         %retval = invoke i32 @Test(i32 15) to label %Continue
      @@ -2381,16 +2509,15 @@ The result value has the same type as its operands.

      Arguments:

      The two arguments to the 'add' instruction must be integer, floating point, or - vector values. Both arguments must have identical - types.

      + href="#t_integer">integer or + vector of integer values. Both arguments must + have identical types.

      Semantics:
      -

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

      +

      The value produced is the integer sum of the two operands.

      -

      If an integer sum has unsigned overflow, the result returned is the +

      If the sum has unsigned overflow, the result returned is the mathematical result modulo 2n, where n is the bit width of the result.

      @@ -2404,6 +2531,39 @@ instruction is appropriate for both signed and unsigned integers.

      + + +
      + +
      Syntax:
      + +
      +  <result> = fadd <ty> <op1>, <op2>   ; yields {ty}:result
      +
      + +
      Overview:
      + +

      The 'fadd' instruction returns the sum of its two operands.

      + +
      Arguments:
      + +

      The two arguments to the 'fadd' instruction must be +floating point or vector of +floating point values. Both arguments must have identical types.

      + +
      Semantics:
      + +

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

      + +
      Example:
      + +
      +  <result> = fadd float 4.0, %var          ; yields {float}:result = 4.0 + %var
      +
      +
      + @@ -2428,16 +2588,14 @@ representations.

      Arguments:

      The two arguments to the 'sub' instruction must be integer, floating point, - or vector values. Both arguments must have identical - types.

      + href="#t_integer">integer or vector of + integer values. Both arguments must have identical types.

      Semantics:
      -

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

      +

      The value produced is the integer difference of the two operands.

      -

      If an integer difference has unsigned overflow, the result returned is the +

      If the difference has unsigned overflow, the result returned is the mathematical result modulo 2n, where n is the bit width of the result.

      @@ -2451,6 +2609,45 @@ instruction is appropriate for both signed and unsigned integers.

      + + + +
      + +
      Syntax:
      + +
      +  <result> = fsub <ty> <op1>, <op2>   ; yields {ty}:result
      +
      + +
      Overview:
      + +

      The 'fsub' instruction returns the difference of its two +operands.

      + +

      Note that the 'fsub' instruction is used to represent the +'fneg' instruction present in most other intermediate +representations.

      + +
      Arguments:
      + +

      The two arguments to the 'fsub' instruction must be floating point or vector + of floating point values. Both arguments must have identical types.

      + +
      Semantics:
      + +

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

      + +
      Example:
      +
      +  <result> = fsub float 4.0, %var           ; yields {float}:result = 4.0 - %var
      +  <result> = fsub float -0.0, %val          ; yields {float}:result = -%var
      +
      +
      +
      'mul' Instruction @@ -2468,16 +2665,14 @@ operands.

      Arguments:

      The two arguments to the 'mul' instruction must be integer, floating point, -or vector values. Both arguments must have identical -types.

      +href="#t_integer">integer or vector of integer +values. Both arguments must have identical types.

      Semantics:
      -

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

      +

      The value produced is the integer product of the two operands.

      -

      If the result of an integer multiplication has unsigned overflow, +

      If the result of the multiplication has unsigned overflow, the result returned is the mathematical result modulo 2n, where n is the bit width of the result.

      Because LLVM integers use a two's complement representation, and the @@ -2491,6 +2686,35 @@ width of the full product.

      + + + +
      + +
      Syntax:
      +
        <result> = fmul <ty> <op1>, <op2>   ; yields {ty}:result
      +
      +
      Overview:
      +

      The 'fmul' instruction returns the product of its two +operands.

      + +
      Arguments:
      + +

      The two arguments to the 'fmul' instruction must be +floating point or vector +of floating point values. Both arguments must have identical types.

      + +
      Semantics:
      + +

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

      + +
      Example:
      +
        <result> = fmul float 4.0, %var          ; yields {float}:result = 4.0 * %var
      +
      +
      + @@ -3298,9 +3522,10 @@ address space (address space zero).

      bytes of memory from the operating system and returns a pointer of the appropriate type to the program. If "NumElements" is specified, it is the number of elements allocated, otherwise "NumElements" is defaulted to be one. -If a constant alignment is specified, the value result of the allocation is guaranteed to -be aligned to at least that boundary. If not specified, or if zero, the target can -choose to align the allocation on any convenient boundary.

      +If a constant alignment is specified, the value result of the allocation is +guaranteed to be aligned to at least that boundary. If not specified, or if +zero, the target can choose to align the allocation on any convenient boundary +compatible with the type.

      'type' must be a sized type.

      @@ -3391,15 +3616,16 @@ space (address space zero).

      bytes of memory on the runtime stack, returning a pointer of the appropriate type to the program. If "NumElements" is specified, it is the number of elements allocated, otherwise "NumElements" is defaulted to be one. -If a constant alignment is specified, the value result of the allocation is guaranteed -to be aligned to at least that boundary. If not specified, or if zero, the target -can choose to align the allocation on any convenient boundary.

      +If a constant alignment is specified, the value result of the allocation is +guaranteed to be aligned to at least that boundary. If not specified, or if +zero, the target can choose to align the allocation on any convenient boundary +compatible with the type.

      'type' may be any sized type.

      Semantics:
      -

      Memory is allocated; a pointer is returned. The operation is undefiend if +

      Memory is allocated; a pointer is returned. The operation is undefined if there is insufficient stack space for the allocation. 'alloca'd memory is automatically released when the function returns. The 'alloca' instruction is commonly used to represent automatic variables that must @@ -3445,7 +3671,13 @@ alignment may produce less efficient code. An alignment of 1 is always safe.

      Semantics:
      -

      The location of memory pointed to is loaded.

      +

      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 of bytes needed to hold all bits of the type. For example, loading an +i24 reads at most three bytes. When loading a value of a type like +i20 with a size that is not an integral number of bytes, the result +is undefined if the value was not originally written using a store of the +same type.

      Examples:
        %ptr = alloca i32                               ; yields {i32*}:ptr
         
       
      Semantics:

      The contents of memory are updated to contain '<value>' -at the location specified by the '<pointer>' operand.

      +at the location specified by the '<pointer>' operand. +If '<value>' is of scalar type then the number of bytes +written does not exceed the minimum number of bytes needed to hold all +bits of the type. For example, storing an i24 writes at most +three bytes. When writing a value of a type like i20 with a +size that is not an integral number of bytes, it is unspecified what +happens to the extra bits that do not belong to the type, but they will +typically be overwritten.

      Example:
        %ptr = alloca i32                               ; yields {i32*}:ptr
         store i32 3, i32* %ptr                          ; yields {void}
      @@ -3526,8 +3765,7 @@ the pointer before continuing calculation.

      The type of each index argument depends on the type it is indexing into. When indexing into a (packed) structure, only i32 integer constants are allowed. When indexing into an array, pointer or vector, -only integers of 32 or 64 bits are allowed (also non-constants). 32-bit values -will be sign extended to 64-bits if required.

      +integers of any width are allowed (also non-constants).

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

      @@ -3593,11 +3831,13 @@ the LLVM code for the given testcase is equivalent to:

      }
      -

      Note that it is undefined to access an array out of bounds: array and -pointer indexes must always be within the defined bounds of the array type. -The one exception for this rule is zero length arrays. These arrays are -defined to be accessible as variable length arrays, which requires access -beyond the zero'th element.

      +

      Note that it is undefined to access an array out of bounds: array +and pointer indexes must always be within the defined bounds of the +array type when accessed with an instruction that dereferences the +pointer (e.g. a load or store instruction). The one exception for +this rule is zero length arrays. These arrays are defined to be +accessible as variable length arrays, which requires access beyond the +zero'th element.

      The getelementptr instruction is often confusing. For some more insight into how it works, see the getelementptr @@ -3612,6 +3852,8 @@ FAQ.

      %vptr = getelementptr {i32, <2 x i8>}* %svptr, i64 0, i32 1, i32 1 ; yields i8*:eptr %eptr = getelementptr [12 x i8]* %aptr, i64 0, i32 1 + ; yields i32*:iptr + %iptr = getelementptr [10 x i32]* @arr, i16 0, i16 0
      @@ -4252,109 +4494,6 @@ always yields an i1 result, as follows:

      - - -
      -
      Syntax:
      -
        <result> = vicmp <cond> <ty> <op1>, <op2>   ; yields {ty}:result
      -
      -
      Overview:
      -

      The 'vicmp' instruction returns an integer vector value based on -element-wise comparison of its two integer vector operands.

      -
      Arguments:
      -

      The 'vicmp' instruction takes three operands. The first operand is -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. -
      3. ne: not equal
      4. -
      5. ugt: unsigned greater than
      6. -
      7. uge: unsigned greater or equal
      8. -
      9. ult: unsigned less than
      10. -
      11. ule: unsigned less or equal
      12. -
      13. sgt: signed greater than
      14. -
      15. sge: signed greater or equal
      16. -
      17. slt: signed less than
      18. -
      19. sle: signed less or equal
      20. -
      -

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

      -
      Semantics:
      -

      The 'vicmp' instruction compares op1 and op2 -according to the condition code given as cond. The comparison yields a -vector of integer result, of -identical type as the values being compared. The most significant bit in each -element is 1 if the element-wise comparison evaluates to true, and is 0 -otherwise. All other bits of the result are undefined. The condition codes -are evaluated identically to the 'icmp' -instruction.

      - -
      Example:
      -
      -  <result> = vicmp eq <2 x i32> < i32 4, i32 0>, < i32 5, i32 0>   ; yields: result=<2 x i32> < i32 0, i32 -1 >
      -  <result> = vicmp ult <2 x i8 > < i8 1, i8 2>, < i8 2, i8 2 >        ; yields: result=<2 x i8> < i8 -1, i8 0 >
      -
      -
      - - - -
      -
      Syntax:
      -
        <result> = vfcmp <cond> <ty> <op1>, <op2>
      -
      Overview:
      -

      The 'vfcmp' instruction returns an integer vector value based on -element-wise comparison of its two floating point vector operands. The output -elements have the same width as the input elements.

      -
      Arguments:
      -

      The 'vfcmp' instruction takes three operands. The first operand is -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. -
      3. oeq: ordered and equal
      4. -
      5. ogt: ordered and greater than
      6. -
      7. oge: ordered and greater than or equal
      8. -
      9. olt: ordered and less than
      10. -
      11. ole: ordered and less than or equal
      12. -
      13. one: ordered and not equal
      14. -
      15. ord: ordered (no nans)
      16. -
      17. ueq: unordered or equal
      18. -
      19. ugt: unordered or greater than
      20. -
      21. uge: unordered or greater than or equal
      22. -
      23. ult: unordered or less than
      24. -
      25. ule: unordered or less than or equal
      26. -
      27. une: unordered or not equal
      28. -
      29. uno: unordered (either nans)
      30. -
      31. true: no comparison, always returns true
      32. -
      -

      The remaining two arguments must be vector of -floating point typed. They must also be identical -types.

      -
      Semantics:
      -

      The 'vfcmp' instruction compares op1 and op2 -according to the condition code given as cond. The comparison yields a -vector of integer result, with -an identical number of elements as the values being compared, and each element -having identical with to the width of the floating point elements. The most -significant bit in each element is 1 if the element-wise comparison evaluates to -true, and is 0 otherwise. All other bits of the result are undefined. The -condition codes are evaluated identically to the -'fcmp' instruction.

      - -
      Example:
      -
      -  ; yields: result=<2 x i32> < i32 0, i32 -1 >
      -  <result> = vfcmp oeq <2 x float> < float 4, float 0 >, < float 5, float 0 >
      -  
      -  ; yields: result=<2 x i64> < i64 -1, i64 0 >
      -  <result> = vfcmp ult <2 x double> < double 1, double 2 >, < double 2, double 2>
      -
      -
      -
      'phi' Instruction @@ -4381,6 +4520,11 @@ may be used as the label arguments.

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

      +

      For the purposes of the SSA form, the use of each incoming value is +deemed to occur on the edge from the corresponding predecessor block +to the current block (but after any definition of an 'invoke' +instruction's return value on the same edge).

      +
      Semantics:

      At runtime, the 'phi' instruction logically takes on the value @@ -5684,7 +5828,7 @@ additional even-byte lengths (6 bytes, 8 bytes and more, respectively).

      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 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>)
      @@ -5796,103 +5940,308 @@ of src.  For example, llvm.cttz(2) = 1.
       

      + + + + +
      +

      +LLVM provides intrinsics for some arithmetic with overflow operations. +

      + +
      +
      Syntax:
      -

      This is an overloaded intrinsic. You can use llvm.part.select + +

      This is an overloaded intrinsic. You can use llvm.sadd.with.overflow on any integer bit width.

      +
      -  declare i17 @llvm.part.select.i17 (i17 %val, i32 %loBit, i32 %hiBit)
      -  declare i29 @llvm.part.select.i29 (i29 %val, i32 %loBit, i32 %hiBit)
      +  declare {i16, i1} @llvm.sadd.with.overflow.i16(i16 %a, i16 %b)
      +  declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
      +  declare {i64, i1} @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)
       
      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.

      + +

      The 'llvm.sadd.with.overflow' family of intrinsic functions perform +a signed addition of the two arguments, and indicate whether an overflow +occurred during the signed summation.

      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.

      + +

      The arguments (%a and %b) and the first element of the result structure may +be of integer types of any bit width, but they must have the same bit width. The +second element of the result structure must be of type i1. %a +and %b are the two values that will undergo signed addition.

      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.
      8. -
      -

      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).

      + +

      The 'llvm.sadd.with.overflow' family of intrinsic functions perform +a signed addition of the two variables. They return a structure — the +first element of which is the signed summation, and the second element of which +is a bit specifying if the signed summation resulted in an overflow.

      + +
      Examples:
      +
      +  %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
      +  %sum = extractvalue {i32, i1} %res, 0
      +  %obit = extractvalue {i32, i1} %res, 1
      +  br i1 %obit, label %overflow, label %normal
      +
      + +
      + + + + +
      + +
      Syntax:
      + +

      This is an overloaded intrinsic. You can use llvm.uadd.with.overflow +on any integer bit width.

      + +
      +  declare {i16, i1} @llvm.uadd.with.overflow.i16(i16 %a, i16 %b)
      +  declare {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
      +  declare {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
      +
      + +
      Overview:
      + +

      The 'llvm.uadd.with.overflow' family of intrinsic functions perform +an unsigned addition of the two arguments, and indicate whether a carry occurred +during the unsigned summation.

      + +
      Arguments:
      + +

      The arguments (%a and %b) and the first element of the result structure may +be of integer types of any bit width, but they must have the same bit width. The +second element of the result structure must be of type i1. %a +and %b are the two values that will undergo unsigned addition.

      + +
      Semantics:
      + +

      The 'llvm.uadd.with.overflow' family of intrinsic functions perform +an unsigned addition of the two arguments. They return a structure — the +first element of which is the sum, and the second element of which is a bit +specifying if the unsigned summation resulted in a carry.

      + +
      Examples:
      +
      +  %res = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
      +  %sum = extractvalue {i32, i1} %res, 0
      +  %obit = extractvalue {i32, i1} %res, 1
      +  br i1 %obit, label %carry, label %normal
      +
      + +
      + + + + +
      + +
      Syntax:
      + +

      This is an overloaded intrinsic. You can use llvm.ssub.with.overflow +on any integer bit width.

      + +
      +  declare {i16, i1} @llvm.ssub.with.overflow.i16(i16 %a, i16 %b)
      +  declare {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
      +  declare {i64, i1} @llvm.ssub.with.overflow.i64(i64 %a, i64 %b)
      +
      + +
      Overview:
      + +

      The 'llvm.ssub.with.overflow' family of intrinsic functions perform +a signed subtraction of the two arguments, and indicate whether an overflow +occurred during the signed subtraction.

      + +
      Arguments:
      + +

      The arguments (%a and %b) and the first element of the result structure may +be of integer types of any bit width, but they must have the same bit width. The +second element of the result structure must be of type i1. %a +and %b are the two values that will undergo signed subtraction.

      + +
      Semantics:
      + +

      The 'llvm.ssub.with.overflow' family of intrinsic functions perform +a signed subtraction of the two arguments. They return a structure — the +first element of which is the subtraction, and the second element of which is a bit +specifying if the signed subtraction resulted in an overflow.

      + +
      Examples:
      +
      +  %res = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
      +  %sum = extractvalue {i32, i1} %res, 0
      +  %obit = extractvalue {i32, i1} %res, 1
      +  br i1 %obit, label %overflow, label %normal
      +
      +
      +
      Syntax:
      -

      This is an overloaded intrinsic. You can use llvm.part.set + +

      This is an overloaded intrinsic. You can use llvm.usub.with.overflow on any integer bit width.

      +
      -  declare i17 @llvm.part.set.i17.i9 (i17 %val, i9 %repl, i32 %lo, i32 %hi)
      -  declare i29 @llvm.part.set.i29.i9 (i29 %val, i9 %repl, i32 %lo, i32 %hi)
      +  declare {i16, i1} @llvm.usub.with.overflow.i16(i16 %a, i16 %b)
      +  declare {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
      +  declare {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
       
      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.

      + +

      The 'llvm.usub.with.overflow' family of intrinsic functions perform +an unsigned subtraction of the two arguments, and indicate whether an overflow +occurred during the unsigned subtraction.

      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.

      + +

      The arguments (%a and %b) and the first element of the result structure may +be of integer types of any bit width, but they must have the same bit width. The +second element of the result structure must be of type i1. %a +and %b are the two values that will undergo unsigned subtraction.

      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.

      + +

      The 'llvm.usub.with.overflow' family of intrinsic functions perform +an unsigned subtraction of the two arguments. They return a structure — the +first element of which is the subtraction, and the second element of which is a bit +specifying if the unsigned subtraction resulted in an overflow.

      +
      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
      +  %res = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
      +  %sum = extractvalue {i32, i1} %res, 0
      +  %obit = extractvalue {i32, i1} %res, 1
      +  br i1 %obit, label %overflow, label %normal
      +
      + +
      + + + + +
      + +
      Syntax:
      + +

      This is an overloaded intrinsic. You can use llvm.smul.with.overflow +on any integer bit width.

      + +
      +  declare {i16, i1} @llvm.smul.with.overflow.i16(i16 %a, i16 %b)
      +  declare {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
      +  declare {i64, i1} @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
       
      + +
      Overview:
      + +

      The 'llvm.smul.with.overflow' family of intrinsic functions perform +a signed multiplication of the two arguments, and indicate whether an overflow +occurred during the signed multiplication.

      + +
      Arguments:
      + +

      The arguments (%a and %b) and the first element of the result structure may +be of integer types of any bit width, but they must have the same bit width. The +second element of the result structure must be of type i1. %a +and %b are the two values that will undergo signed multiplication.

      + +
      Semantics:
      + +

      The 'llvm.smul.with.overflow' family of intrinsic functions perform +a signed multiplication of the two arguments. They return a structure — +the first element of which is the multiplication, and the second element of +which is a bit specifying if the signed multiplication resulted in an +overflow.

      + +
      Examples:
      +
      +  %res = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
      +  %sum = extractvalue {i32, i1} %res, 0
      +  %obit = extractvalue {i32, i1} %res, 1
      +  br i1 %obit, label %overflow, label %normal
      +
      + +
      + + + + +
      + +
      Syntax:
      + +

      This is an overloaded intrinsic. You can use llvm.umul.with.overflow +on any integer bit width.

      + +
      +  declare {i16, i1} @llvm.umul.with.overflow.i16(i16 %a, i16 %b)
      +  declare {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
      +  declare {i64, i1} @llvm.umul.with.overflow.i64(i64 %a, i64 %b)
      +
      + +
      Overview:
      + +

      The 'llvm.umul.with.overflow' family of intrinsic functions perform +a unsigned multiplication of the two arguments, and indicate whether an overflow +occurred during the unsigned multiplication.

      + +
      Arguments:
      + +

      The arguments (%a and %b) and the first element of the result structure may +be of integer types of any bit width, but they must have the same bit width. The +second element of the result structure must be of type i1. %a +and %b are the two values that will undergo unsigned +multiplication.

      + +
      Semantics:
      + +

      The 'llvm.umul.with.overflow' family of intrinsic functions perform +an unsigned multiplication of the two arguments. They return a structure — +the first element of which is the multiplication, and the second element of +which is a bit specifying if the unsigned multiplication resulted in an +overflow.

      + +
      Examples:
      +
      +  %res = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
      +  %sum = extractvalue {i32, i1} %res, 0
      +  %obit = extractvalue {i32, i1} %res, 1
      +  br i1 %obit, label %overflow, label %normal
      +
      +