diff --git a/docs/LangRef.html b/docs/LangRef.html index d09d34860e2..7796126b62d 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -144,6 +144,7 @@
  • 'select' Instruction
  • 'call' Instruction
  • 'va_arg' Instruction
  • +
  • 'getresult' Instruction
  • @@ -1226,16 +1227,16 @@ consists of a return type and a list of formal parameter 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:
    @@ -1788,6 +1789,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 @@ -1796,11 +1798,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 'first class' + type. Notice that a function is not well formed +if there exists a 'ret' instruction inside of the function that +returns values that does 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 +value can only be accessed through 'getresult +' insctruction.

    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  
     
    @@ -1922,7 +1927,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 accessed only through +'getresult' instruction.

    Arguments:
    @@ -3810,7 +3817,10 @@ 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 +function is bound to the result argument. If the 'ret +' instruction returns multiple values then the return value of the +function is only accessed through 'getresult +' instruction. This is a simpler case of the invoke instruction.

    Example:
    @@ -3821,6 +3831,11 @@ the invoke instruction.

    %X = tail call i32 @foo() %Y = tail call fastcc i32 @foo() %Z = call void %foo(i8 97 signext) + + %struct.A = type { i32, i8 } + %r = call %struct.A @foo() + %gr = getresult %struct.A %r, 0 + %gr1 = getresult %struct.A %r, 1 @@ -3873,6 +3888,48 @@ argument.

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

    The 'getresult' instruction is used to extract individual values +from multiple values returned by 'call' +or 'invoke' instruction. + +

    Arguments:
    + +The 'getresult' instruction takes return value as first argument. The +value must have structure type. The second argument +is unsigned index value. + +
    Semantics:
    + +The 'getresult' instruction extracts 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
    +  %gr1 = getresult %struct.A %r, 1 
    +  add i32 %gr, 42
    +  add i8 %gr1, 41
    +
    + +
    +
    Intrinsic Functions