X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.html;h=e44edf421fd12259eb33a6948beb3c399791691b;hb=3a5bff8d04dd028cf3e0bbd3c28069c03a501f5a;hp=515f956ed00af196ed413edf7cd5af19bdf00840;hpb=117bbd37b8cf4f58d8b7591ca97832d560ed2ee7;p=oota-llvm.git diff --git a/docs/LangRef.html b/docs/LangRef.html index 515f956ed00..e44edf421fd 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -144,6 +144,7 @@
  • 'select' Instruction
  • 'call' Instruction
  • 'va_arg' Instruction
  • +
  • 'getresult' Instruction
  • @@ -206,7 +207,10 @@
  • Atomic intrinsics
      -
    1. llvm.memory_barrier
    2. +
    3. llvm.memory_barrier
    4. +
    5. llvm.atomic.lcs
    6. +
    7. llvm.atomic.las
    8. +
    9. llvm.atomic.swap
  • General intrinsics @@ -759,8 +763,8 @@ a power of 2.

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

    Syntax:
    @@ -823,8 +827,10 @@ declare i32 @atoi(i8*) nounwind readonly value, but is also valid on scalars (even though this is silly).
    sret
    -
    This indicates that the parameter specifies the address of a structure - that is the return value of the function in the source program.
    +
    This indicates that the pointer parameter specifies the address of a + structure that is the return value of the function in the source program. + Loads and stores to the structure are assumed not to trap. + May only be applied to the first parameter.
    noalias
    This indicates that the parameter does not alias any global or any other @@ -837,10 +843,11 @@ declare i32 @atoi(i8*) nounwind readonly an unreachable instruction immediately followed the call.
    nounwind
    -
    This function attribute indicates that the function type does not use - the unwind instruction and does not allow stack unwinding to propagate - through it.
    - +
    This function attribute indicates that no exceptions unwind out of the + function. Usually this is because the function makes no use of exceptions, + but it may also be that the function catches any exceptions thrown when + executing it.
    +
    nest
    This indicates that the parameter can be excised using the trampoline intrinsics.
    @@ -1218,20 +1225,22 @@ type "{ i32, [0 x float]}", for example.

    Overview:

    The function type can be thought of as a function signature. It -consists of a return type and a list of formal parameter types. -Function types are usually used to build virtual function tables +consists of a return type and a list of formal parameter types. The +return type of a function type is a scalar type or a struct type. If the +return type is a struct type then all struct elements must be of first +class types. Function types are usually used to build virtual function tables (which are structures of pointers to functions), for indirect function calls, and when defining a function.

    -

    -The return type of a function type cannot be an aggregate type. -

    +
    Syntax:
    -
      <returntype> (<parameter list>)
    +
      <returntype list> (<parameter list>)

    ...where '<parameter list>' is a comma-separated list of type specifiers. Optionally, the parameter list may include a type ..., which indicates that the function takes a variable number of arguments. Variable argument functions can access their arguments with the variable argument handling intrinsic functions.

    + href="#int_varargs">variable argument handling intrinsic functions. +'<returntype list>' is a comma-separated list of +first class type specifiers.

    Examples:
    @@ -1253,6 +1262,11 @@ Variable argument functions can access their arguments with the printf in LLVM. + + +
    {i32, i32} (i32)A function taking an i32>, returning two + i32 values as an aggregate of type { i32, i32 } +
    @@ -1784,6 +1798,7 @@ Instruction
    Syntax:
      ret <type> <value>       ; Return a value from a non-void function
       ret void                 ; Return from void function
    +  ret <type> <value>, <type> <value>  ; Return two values from a non-void function 
     
    Overview:

    The 'ret' instruction is used to return control flow (and a @@ -1792,11 +1807,11 @@ value) from a function back to the caller.

    returns a value and then causes control flow, and one that just causes control flow to occur.

    Arguments:
    -

    The 'ret' instruction may return any 'first class' type. Notice that a function is -not well formed if there exists a 'ret' -instruction inside of the function that returns a value that does not -match the return type of the function.

    +

    The 'ret' instruction may return one or multiple values. The +type of each return value must be a 'first class' + type. Note that a function is not well formed +if there exists a 'ret' instruction inside of the function that +returns values that do not match the return type of the function.

    Semantics:

    When the 'ret' instruction is executed, control flow returns back to the calling function's context. If the caller is a "invoke" instruction, execution continues at the beginning of the "normal" destination block. If the instruction returns a value, that value shall set the call or invoke instruction's -return value.

    +return value. If the instruction returns multiple values then these +values can only be accessed through a 'getresult +' instruction.

    Example:
      ret i32 5                       ; Return an integer value of 5
       ret void                        ; Return from a void function
    +  ret i32 4, i8 2                 ; Return two values 4 and 2  
     
    @@ -1905,7 +1923,7 @@ branches or with a lookup table.

    Syntax:
    -  <result> = invoke [cconv] <ptr to function ty> %<function ptr val>(<function args>) 
    +  <result> = invoke [cconv] <ptr to function ty> <function ptr val>(<function args>) 
                     to label <normal label> unwind label <exception label>
     
    @@ -1918,7 +1936,9 @@ function, with the possibility of control flow transfer to either 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.

    +continued at the dynamically nearest "exception" label. If the callee function +returns multiple values then individual return values are only accessible through +a 'getresult' instruction.

    Arguments:
    @@ -1966,9 +1986,9 @@ exception. Additionally, this is important for implementation of
    Example:
    -  %retval = invoke i32 %Test(i32 15) to label %Continue
    +  %retval = invoke i32 @Test(i32 15) to label %Continue
                   unwind label %TestCleanup              ; {i32}:retval set
    -  %retval = invoke coldcc i32 %Test(i32 15) to label %Continue
    +  %retval = invoke coldcc i32 %Testfnptr(i32 15) to label %Continue
                   unwind label %TestCleanup              ; {i32}:retval set
     
    @@ -3806,17 +3826,23 @@ transfer to a specified function, with its incoming arguments bound to the specified values. Upon a 'ret' instruction in the called function, control flow continues with the instruction after the function call, and the return value of the -function is bound to the result argument. This is a simpler case of -the invoke instruction.

    +function is bound to the result argument. If the callee returns multiple +values then the return values of the function are only accessible through +the 'getresult' instruction.

    Example:
       %retval = call i32 @test(i32 %argc)
    -  call i32 (i8 *, ...)* @printf(i8 * %msg, i32 12, i8 42);
    -  %X = tail call i32 @foo()
    -  %Y = tail call fastcc i32 @foo()
    -  %Z = call void %foo(i8 97 signext)
    +  call i32 (i8 *, ...)* @printf(i8 * %msg, i32 12, i8 42)      ; yields i32
    +  %X = tail call i32 @foo()                                    ; yields i32
    +  %Y = tail call fastcc i32 @foo()  ; yields i32
    +  call void %foo(i8 97 signext)
    +
    +  %struct.A = type { i32, i8 }
    +  %r = call %struct.A @foo()                     ; yields { 32, i8 }
    +  %gr = getresult %struct.A %r, 0                ; yields i32
    +  %gr1 = getresult %struct.A %r, 1               ; yields i8
     
    @@ -3869,6 +3895,51 @@ argument.

    + +
    + 'getresult' Instruction +
    + +
    + +
    Syntax:
    +
    +  <resultval> = getresult <type> <retval>, <index>
    +
    + +
    Overview:
    + +

    The 'getresult' instruction is used to extract individual values +from a 'call' +or 'invoke' instruction that returns multiple +results.

    + +
    Arguments:
    + +

    The 'getresult' instruction takes a call or invoke value as its +first argument. The value must have structure type. +The second argument is an unsigned index value which must be in range for +the number of values returned by the call.

    + +
    Semantics:
    + +

    The 'getresult' instruction extracts the element identified by +'index' from the aggregate value.

    + +
    Example:
    + +
    +  %struct.A = type { i32, i8 }
    +
    +  %r = call %struct.A @foo()
    +  %gr = getresult %struct.A %r, 0    ; yields i32:%gr
    +  %gr1 = getresult %struct.A %r, 1   ; yields i8:%gr1
    +  add i32 %gr, 42
    +  add i8 %gr1, 41
    +
    + +
    +
    Intrinsic Functions
    @@ -5338,6 +5409,176 @@ i1 <device> ) + +
    + 'llvm.atomic.lcs.*' Intrinsic +
    +
    +
    Syntax:
    +

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

    + +
    +declare i8 @llvm.atomic.lcs.i8( i8* <ptr>, i8 <cmp>, i8 <val> )
    +declare i16 @llvm.atomic.lcs.i16( i16* <ptr>, i16 <cmp>, i16 <val> )
    +declare i32 @llvm.atomic.lcs.i32( i32* <ptr>, i32 <cmp>, i32 <val> )
    +declare i64 @llvm.atomic.lcs.i64( i64* <ptr>, i64 <cmp>, i64 <val> )
    +
    +
    +
    Overview:
    +

    + This loads a value in memory and compares it to a given value. If they are + equal, it stores a new value into the memory. +

    +
    Arguments:
    +

    + The llvm.atomic.lcs intrinsic takes three arguments. The result as + well as both cmp and val must be integer values with the + same bit width. The ptr argument must be a pointer to a value of + this integer type. While any bit width integer may be used, targets may only + lower representations they support in hardware. + +

    +
    Semantics:
    +

    + This entire intrinsic must be executed atomically. It first loads the value + in memory pointed to by ptr and compares it with the value + cmp. If they are equal, val is stored into the memory. The + loaded value is yielded in all cases. This provides the equivalent of an + atomic compare-and-swap operation within the SSA framework. +

    +
    Examples:
    + +
    +%ptr      = malloc i32
    +            store i32 4, %ptr
    +
    +%val1     = add i32 4, 4
    +%result1  = call i32 @llvm.atomic.lcs.i32( i32* %ptr, i32 4, %val1 )
    +                                          ; yields {i32}:result1 = 4
    +%stored1  = icmp eq i32 %result1, 4       ; yields {i1}:stored1 = true
    +%memval1  = load i32* %ptr                ; yields {i32}:memval1 = 8
    +
    +%val2     = add i32 1, 1
    +%result2  = call i32 @llvm.atomic.lcs.i32( i32* %ptr, i32 5, %val2 )
    +                                          ; yields {i32}:result2 = 8
    +%stored2  = icmp eq i32 %result2, 5       ; yields {i1}:stored2 = false
    +
    +%memval2  = load i32* %ptr                ; yields {i32}:memval2 = 8
    +
    +
    + + +
    + 'llvm.atomic.swap.*' Intrinsic +
    +
    +
    Syntax:
    + +

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

    +
    +declare i8 @llvm.atomic.swap.i8( i8* <ptr>, i8 <val> )
    +declare i16 @llvm.atomic.swap.i16( i16* <ptr>, i16 <val> )
    +declare i32 @llvm.atomic.swap.i32( i32* <ptr>, i32 <val> )
    +declare i64 @llvm.atomic.swap.i64( i64* <ptr>, i64 <val> )
    +
    +
    +
    Overview:
    +

    + This intrinsic loads the value stored in memory at ptr and yields + the value from memory. It then stores the value in val in the memory + at ptr. +

    +
    Arguments:
    + +

    + The llvm.atomic.ls intrinsic takes two arguments. Both the + val argument and the result must be integers of the same bit width. + The first argument, ptr, must be a pointer to a value of this + integer type. The targets may only lower integer representations they + support. +

    +
    Semantics:
    +

    + This intrinsic loads the value pointed to by ptr, yields it, and + stores val back into ptr atomically. This provides the + equivalent of an atomic swap operation within the SSA framework. + +

    +
    Examples:
    +
    +%ptr      = malloc i32
    +            store i32 4, %ptr
    +
    +%val1     = add i32 4, 4
    +%result1  = call i32 @llvm.atomic.swap.i32( i32* %ptr, i32 %val1 )
    +                                        ; yields {i32}:result1 = 4
    +%stored1  = icmp eq i32 %result1, 4     ; yields {i1}:stored1 = true
    +%memval1  = load i32* %ptr              ; yields {i32}:memval1 = 8
    +
    +%val2     = add i32 1, 1
    +%result2  = call i32 @llvm.atomic.swap.i32( i32* %ptr, i32 %val2 )
    +                                        ; yields {i32}:result2 = 8
    +
    +%stored2  = icmp eq i32 %result2, 8     ; yields {i1}:stored2 = true
    +%memval2  = load i32* %ptr              ; yields {i32}:memval2 = 2
    +
    +
    + + +
    + 'llvm.atomic.las.*' Intrinsic + +
    +
    +
    Syntax:
    +

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

    +
    +declare i8 @llvm.atomic.las.i8.( i8* <ptr>, i8 <delta> )
    +declare i16 @llvm.atomic.las.i16.( i16* <ptr>, i16 <delta> )
    +declare i32 @llvm.atomic.las.i32.( i32* <ptr>, i32 <delta> )
    +declare i64 @llvm.atomic.las.i64.( i64* <ptr>, i64 <delta> )
    +
    +
    +
    Overview:
    +

    + This intrinsic adds delta to the value stored in memory at + ptr. It yields the original value at ptr. +

    +
    Arguments:
    +

    + + The intrinsic takes two arguments, the first a pointer to an integer value + and the second an integer value. The result is also an integer value. These + integer types can have any bit width, but they must all have the same bit + width. The targets may only lower integer representations they support. +

    +
    Semantics:
    +

    + This intrinsic does a series of operations atomically. It first loads the + value stored at ptr. It then adds delta, stores the result + to ptr. It yields the original value stored at ptr. +

    + +
    Examples:
    +
    +%ptr      = malloc i32
    +        store i32 4, %ptr
    +%result1  = call i32 @llvm.atomic.las.i32( i32* %ptr, i32 4 )
    +                                ; yields {i32}:result1 = 4
    +%result2  = call i32 @llvm.atomic.las.i32( i32* %ptr, i32 2 )
    +                                ; yields {i32}:result2 = 8
    +%result3  = call i32 @llvm.atomic.las.i32( i32* %ptr, i32 5 )
    +                                ; yields {i32}:result3 = 10
    +%memval   = load i32* %ptr      ; yields {i32}:memval1 = 15
    +
    +
    +