X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=cd8b7e9f967a5e607af176bccbef90a141901e1f;hb=04eeefb32a3ae7de4cde1908d30bff61e0d6b86e;hp=38bcb02c3bbcf562e1de674a95714e55554464c8;hpb=f3480b94b440188cca9bf48618c39f39f204e908;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index 38bcb02c3bb..cd8b7e9f967 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -111,6 +111,12 @@
  • 'shufflevector' Instruction
  • +
  • Aggregate Operations +
      +
    1. 'extractvalue' Instruction
    2. +
    3. 'insertvalue' Instruction
    4. +
    +
  • Memory Access and Addressing Operations
    1. 'malloc' Instruction
    2. @@ -460,7 +466,7 @@ All Global Variables and Functions have one of the following types of linkage:
      -
      internal
      +
      internal:
      Global values with internal linkage are only directly accessible by objects in the current module. In particular, linking code into a module with @@ -479,14 +485,22 @@ All Global Variables and Functions have one of the following types of linkage: allowed to be discarded.
      +
      common:
      + +
      "common" linkage is exactly the same as linkonce + linkage, except that unreferenced common globals may not be + discarded. This is used for globals that may be emitted in multiple + translation units, but that are not guaranteed to be emitted into every + translation unit that uses them. One example of this is tentative + definitions in C, such as "int X;" at global scope. +
      +
      weak:
      -
      "weak" linkage is exactly the same as linkonce linkage, - except that unreferenced weak globals may not be discarded. This is - used for globals that may be emitted in multiple translation units, but that - are not guaranteed to be emitted into every translation unit that uses them. - One example of this are common globals in C, such as "int X;" at - global scope. +
      "weak" linkage is the same as common linkage, except + that some targets may choose to emit different assembly sequences for them + for target-dependent reasons. This is used for globals that are declared + "weak" in C source code.
      appending:
      @@ -580,9 +594,11 @@ the future:

      (e.g. by passing things in registers). This calling convention allows the target to use whatever tricks it wants to produce fast code for the target, without having to conform to an externally specified ABI. Implementations of - this convention should allow arbitrary tail call optimization to be supported. - This calling convention does not support varargs and requires the prototype of - all callees to exactly match the prototype of the function definition. + this convention should allow arbitrary + tail call optimization to be + supported. This calling convention does not support varargs and requires the + prototype of all callees to exactly match the prototype of the function + definition.
      "coldcc" - The cold calling convention:
      @@ -1029,14 +1045,16 @@ classifications:

      integer, floating point, pointer, - vector + vector, + structure, + array, + label. primitive label, void, - integer, floating point. @@ -1056,8 +1074,7 @@ classifications:

      The first class types are perhaps the most important. Values of these types are the only ones which can be produced by instructions, passed as arguments, or used as operands to -instructions. This means that all structures and arrays must be -manipulated either by pointer or by component.

      +instructions.

      @@ -2085,82 +2102,121 @@ The result value has the same type as its operands.

      There are several different binary operators:

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

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

      +
      Arguments:
      -

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

      + +

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

      +
      Semantics:
      +

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

      +

      If an integer sum 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, this instruction is appropriate for both signed and unsigned integers.

      +
      Example:
      -
        <result> = add i32 4, %var          ; yields {i32}:result = 4 + %var
      +
      +
      +  <result> = add i32 4, %var          ; yields {i32}:result = 4 + %var
       
      - + +
      +
      Syntax:
      -
        <result> = sub <ty> <var1>, <var2>   ; yields {ty}:result
      +
      +
      +  <result> = sub <ty> <var1>, <var2>   ; yields {ty}:result
       
      +
      Overview:
      +

      The 'sub' instruction returns the difference of its two operands.

      -

      Note that the 'sub' instruction is used to represent the 'neg' -instruction present in most other intermediate representations.

      + +

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

      +
      Arguments:
      -

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

      + +

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

      +
      Semantics:
      +

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

      +

      If an integer difference 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, this instruction is appropriate for both signed and unsigned integers.

      +
      Example:
         <result> = sub i32 4, %var          ; yields {i32}:result = 4 - %var
         <result> = sub i32 0, %val          ; yields {i32}:result = -%var
       
      + - + +
      +
      Syntax:
        <result> = mul <ty> <var1>, <var2>   ; yields {ty}:result
       
      Overview:

      The 'mul' instruction returns the product of its two operands.

      +
      Arguments:
      -

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

      + +

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

      +
      Semantics:
      +

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

      +

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

      @@ -2174,6 +2230,7 @@ width of the full product.

        <result> = mul i32 4, %var          ; yields {i32}:result = 4 * %var
       
      + @@ -2184,12 +2241,15 @@ width of the full product.

      Overview:

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

      +
      Arguments:
      +

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

      +integer or vector of integer +values. Both arguments must have identical types.

      +
      Semantics:
      +

      The value produced is the unsigned integer quotient of the two operands.

      Note that unsigned integer division and signed integer division are distinct operations; for signed integer division, use 'sdiv'.

      @@ -2203,16 +2263,21 @@ operations; for signed integer division, use 'sdiv'.

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

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

      +
      Arguments:
      -

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

      + +

      The two arguments to the 'sdiv' instruction must be +integer or vector of integer +values. Both arguments must have identical types.

      +
      Semantics:

      The value produced is the signed integer quotient of the two operands rounded towards zero.

      Note that signed integer division and unsigned integer division are distinct @@ -2229,22 +2294,31 @@ by doing a 32-bit division of -2147483648 by -1.

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

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

      +
      Arguments:
      +

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

      +floating point or vector +of floating point values. Both arguments must have identical types.

      +
      Semantics:
      +

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

      +
      Example:
      -
        <result> = fdiv float 4.0, %var          ; yields {float}:result = 4.0 / %var
      +
      +
      +  <result> = fdiv float 4.0, %var          ; yields {float}:result = 4.0 / %var
       
      + @@ -2256,10 +2330,9 @@ versions of floating point values.

      The 'urem' instruction returns the remainder from the unsigned division of its two arguments.

      Arguments:
      -

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

      +

      The two arguments to the 'urem' instruction must be +integer or vector of integer +values. Both arguments must have identical types.

      Semantics:

      This instruction returns the unsigned integer remainder of a division. This instruction always performs an unsigned division to get the remainder.

      @@ -2272,23 +2345,33 @@ distinct operations; for signed integer remainder, use 'srem'.

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

      The 'srem' instruction returns the remainder from the signed division of its two operands. This instruction can also take vector versions of the values in which case the elements must be integers.

      Arguments:
      +

      The two arguments to the 'srem' instruction must be -integer values. Both arguments must have identical -types.

      +integer or vector of integer +values. Both arguments must have identical types.

      +
      Semantics:
      +

      This instruction returns the remainder of a division (where the result has the same sign as the dividend, var1), not the modulo operator (where the result has the same sign as the divisor, var2) of @@ -2311,9 +2394,11 @@ and the remainder.)

      - + +
      +
      Syntax:
        <result> = frem <ty> <var1>, <var2>   ; yields {ty}:result
       
      @@ -2322,14 +2407,18 @@ Instruction
      division of its two operands.

      Arguments:

      The two arguments to the 'frem' instruction must be -floating point values. Both arguments must have -identical types. This instruction can also take vector -versions of floating point values.

      +floating point or vector +of floating point values. Both arguments must have identical types.

      +
      Semantics:
      +

      This instruction returns the remainder of a division. The remainder has the same sign as the dividend.

      +
      Example:
      -
        <result> = frem float 4.0, %var          ; yields {float}:result = 4.0 % %var
      +
      +
      +  <result> = frem float 4.0, %var          ; yields {float}:result = 4.0 % %var
       
      @@ -2361,7 +2450,8 @@ the left a specified number of bits.

      Both arguments to the 'shl' instruction must be the same integer type. 'var2' is treated as an -unsigned value.

      +unsigned value. This instruction does not support +vector operands.

      Semantics:
      @@ -2391,7 +2481,8 @@ operand shifted to the right a specified number of bits with zero fill.

      Arguments:

      Both arguments to the 'lshr' instruction must be the same integer type. 'var2' is treated as an -unsigned value.

      +unsigned value. This instruction does not support +vector operands.

      Semantics:
      @@ -2426,7 +2517,8 @@ operand shifted to the right a specified number of bits with sign extension.

      Arguments:

      Both arguments to the 'ashr' instruction must be the same integer type. 'var2' is treated as an -unsigned value.

      +unsigned value. This instruction does not support +vector operands.

      Semantics:

      This instruction always performs an arithmetic shift right operation, @@ -2448,17 +2540,26 @@ larger than the number of bits in var1, the result is undefined.

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

      The 'and' instruction returns the bitwise logical and of its two operands.

      +
      Arguments:
      -

      The two arguments to the 'and' instruction must be integer values. Both arguments must have -identical types.

      + +

      The two arguments to the 'and' instruction must be +integer or vector of integer +values. Both arguments must have identical types.

      +
      Semantics:

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

      @@ -2494,7 +2595,8 @@ identical types.

      Example:
      -
        <result> = and i32 4, %var         ; yields {i32}:result = 4 & %var
      +
      +  <result> = and i32 4, %var         ; yields {i32}:result = 4 & %var
         <result> = and i32 15, 40          ; yields {i32}:result = 8
         <result> = and i32 4, 8            ; yields {i32}:result = 0
       
      @@ -2509,9 +2611,10 @@ identical types.

      The 'or' instruction returns the bitwise logical inclusive or of its two operands.

      Arguments:
      -

      The two arguments to the 'or' instruction must be integer values. Both arguments must have -identical types.

      + +

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

      Semantics:

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

      @@ -2564,10 +2667,12 @@ Instruction or of its two operands. The xor is used to implement the "one's complement" operation, which is the "~" operator in C.

      Arguments:
      -

      The two arguments to the 'xor' instruction must be integer values. Both arguments must have -identical types.

      +

      The two arguments to the 'xor' instruction must be +integer or vector of integer +values. Both arguments must have identical types.

      +
      Semantics:
      +

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

      @@ -2773,6 +2878,114 @@ operand may be undef if performing a shuffle from only one vector.
      + + + +
      + +

      LLVM supports several instructions for working with aggregate values. +

      + +
      + + + + +
      + +
      Syntax:
      + +
      +  <result> = extractvalue <aggregate type> <val>, <idx>{, <idx>}*
      +
      + +
      Overview:
      + +

      +The 'extractvalue' instruction extracts the value of a struct field +or array element from an aggregate value. +

      + + +
      Arguments:
      + +

      +The first operand of an 'extractvalue' instruction is a +value of struct or array +type. The operands are constant indices to specify which value to extract +in a similar manner as indices in a +'getelementptr' instruction. +

      + +
      Semantics:
      + +

      +The result is the value at the position in the aggregate specified by +the index operands. +

      + +
      Example:
      + +
      +  %result = extractvalue {i32, float} %agg, 0    ; yields i32
      +
      +
      + + + + + +
      + +
      Syntax:
      + +
      +  <result> = insertvalue <aggregate type> <val>, <ty> <val>, <idx>    ; yields <n x <ty>>
      +
      + +
      Overview:
      + +

      +The 'insertvalue' instruction inserts a value +into a struct field or array element in an aggregate. +

      + + +
      Arguments:
      + +

      +The first operand of an 'insertvalue' instruction is a +value of struct or array type. +The second operand is a first-class value to insert. +The following operands are constant indices +indicating the position at which to insert the value in a similar manner as +indices in a +'getelementptr' instruction. +The value to insert must have the same type as the value identified +by the indices. + +

      Semantics:
      + +

      +The result is an aggregate of the same type as val. Its +value is that of val except that the value at the position +specified by the indices is that of elt. +

      + +
      Example:
      + +
      +  %result = insertvalue {i32, float} %agg, 1, 0    ; yields {i32, float}
      +
      +
      + +
      Memory Access and Addressing Operations @@ -3540,15 +3753,19 @@ nothing is done (no-op cast).

      Overview:
      +

      The 'bitcast' instruction converts value to type ty2 without changing any bits.

      Arguments:
      +

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

      +type is a pointer, the destination type must also be a pointer. This +instruction supports bitwise conversion of vectors to integers and to vectors +of other types (as long as they have the same size).

      Semantics:

      The 'bitcast' instruction converts value to type @@ -3763,8 +3980,8 @@ 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 >
      +  <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 >
       
      @@ -3817,36 +4034,50 @@ condition codes are evaluated identically to the
      Example:
      -  <result> = vfcmp oeq <2 x float> < float 4, float 0 >, < float 5, float 0 >       ; yields: result=<2 x i32> < i32 0, i32 -1 >
      -  <result> = vfcmp ult <2 x double> < double 1, double 2 >, < double 2, double 2>   ; yields: result=<2 x i64> < i64 -1, i64 0 >
      +  <result> = vfcmp oeq <2 x float> < float 4, float 0 >, < float 5, float 0 >       ; yields: result=<2 x i32> < i32 0, i32 -1 >
      +  <result> = vfcmp ult <2 x double> < double 1, double 2 >, < double 2, double 2>   ; yields: result=<2 x i64> < i64 -1, i64 0 >
       
      - + +
      +
      Syntax:
      +
        <result> = phi <ty> [ <val0>, <label0>], ...
      Overview:

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

      Arguments:
      +

      The type of the incoming values is specified with the first type field. After this, the 'phi' instruction takes a list of pairs as arguments, with one pair for each predecessor basic block of the current block. Only values of first class type may be used as the value arguments to the PHI node. Only labels may be used as the label arguments.

      +

      There must be no non-phi instructions between the start of a basic block and the PHI instructions: i.e. PHI instructions must be first in a basic block.

      +
      Semantics:
      +

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

      +
      Example:
      -
      Loop:       ; Infinite loop that counts from 0 on up...
      %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
      %nextindvar = add i32 %indvar, 1
      br label %Loop
      +
      +Loop:       ; Infinite loop that counts from 0 on up...
      +  %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
      +  %nextindvar = add i32 %indvar, 1
      +  br label %Loop
      +
      @@ -3873,13 +4104,16 @@ condition, without branching.
      Arguments:

      -The 'select' instruction requires a boolean value indicating the condition, and two values of the same first class type. +The 'select' instruction requires an 'i1' value indicating the +condition, and two values of the same first class +type. If the val1/val2 are vectors, the entire vectors are selected, not +individual elements.

      Semantics:

      -If the boolean condition evaluates to true, the instruction returns the first +If the i1 condition evaluates is 1, the instruction returns the first value argument; otherwise, it returns the second value argument.