llvm.org GIT mirror llvm / b1e6b96
Update the documentation for first-class aggregates changes, and remove getresult and references thereto. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57064 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 12 years ago
1 changed file(s) with 24 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
152152
  • 'select' Instruction
  • 153153
  • 'call' Instruction
  • 154154
  • 'va_arg' Instruction
  • 155
  • 'getresult' Instruction
  • 156155
    157156
    158157
    18981897 Instruction
    18991898
    19001899
    Syntax:
    1901
      ret <type> <value>       ; Return a value from a non-void function
                      
                    
    1900
    
                      
                    
    1901 ret <type> <value> ; Return a value from a non-void function
    19021902 ret void ; Return from void function
    1903 ret <type> <value>, <type> <value> ; Return two values from a non-void function
    1904
    1905
    1906
    Overview:
    1907
    1908

    The 'ret' instruction is used to return control flow (and a

    1909 value) from a function back to the caller.>
    1903 >
    1904
    1905
    Overview:
    1906
    1907

    The 'ret' instruction is used to return control flow (and

    1908 optionally a value) from a function back to the caller.

    19101909

    There are two forms of the 'ret' instruction: one that

    1911 returns value(s) and then causes control flow, and one that just causes
    1910 returns a value and then causes control flow, and one that just causes
    19121911 control flow to occur.

    19131912
    19141913
    Arguments:
    19151914
    1916

    The 'ret' instruction may return zero, one or multiple values.

    1917 The type of each return value must be a 'first
    1918 class' type. Note that a function is not well
    1919 formed if there exists a 'ret' instruction inside of the
    1920 function that returns values that do not match the return type of the
    1921 function.

    1915

    The 'ret' instruction optionally accepts a single argument,

    1916 the return value. The type of the return value must be a
    1917 'first class' type.

    1918
    1919

    A function is not well formed if

    1920 it it has a non-void return type and contains a 'ret'
    1921 instruction with no return value or a return value with a type that
    1922 does not match its type, or if it has a void return type and contains
    1923 a 'ret' instruction with a return value.

    19221924
    19231925
    Semantics:
    19241926
    19291931 href="#i_invoke">invoke" instruction, execution continues
    19301932 at the beginning of the "normal" destination block. If the instruction
    19311933 returns a value, that value shall set the call or invoke instruction's
    1932 return value. If the instruction returns multiple values then these
    1933 values can only be accessed through a 'getresult
    1934 ' instruction.

    1934 return value.
    19351935
    19361936
    Example:
    19371937
    19381938
    
                      
                    
    19391939 ret i32 5 ; Return an integer value of 5
    19401940 ret void ; Return from a void function
    1941 ret i32 4, i8 2 ; Return two values 4 and 2
    1941 ret { i32, i8 } { i32 4, i8 2 } ; Return an aggregate of values 4 and 2
    19421942
    19431943
    19441944
    20482048 "ret" instruction, control flow will return to the
    20492049 "normal" label. If the callee (or any indirect callees) returns with the "
    20502050 href="#i_unwind">unwind" instruction, control is interrupted and
    2051 continued at the dynamically nearest "exception" label. If the callee function
    2052 returns multiple values then individual return values are only accessible through
    2053 a 'getresult' instruction.

    2051 continued at the dynamically nearest "exception" label.
    20542052
    20552053
    Arguments:
    20562054
    42884286 the specified values. Upon a 'ret'
    42894287 instruction in the called function, control flow continues with the
    42904288 instruction after the function call, and the return value of the
    4291 function is bound to the result argument. If the callee returns multiple
    4292 values then the return values of the function are only accessible through
    4293 the 'getresult' instruction.

    4289 function is bound to the result argument.
    42944290
    42954291
    Example:
    42964292
    43034299
    43044300 %struct.A = type { i32, i8 }
    43054301 %r = call %struct.A @foo() ; yields { 32, i8 }
    4306 %gr = getresult %struct.A %r, 0 ; yields i32
    4307 %gr1 = getresult %struct.A %r, 1 ; yields i8
    4302 %gr = extractvalue %struct.A %r, 0 ; yields i32
    4303 %gr1 = extractvalue %struct.A %r, 1 ; yields i8
    43084304
    43094305
    43104306
    43544350
    Example:
    43554351
    43564352

    See the variable argument processing section.

    4357
    4358
    4359
    4360
    4361
    4362 'getresult' Instruction
    4363
    4364
    4365
    4366
    4367
    Syntax:
    4368
    
                      
                    
    4369 <resultval> = getresult <type> <retval>, <index>
    4370
    4371
    4372
    Overview:
    4373
    4374

    The 'getresult' instruction is used to extract individual values

    4375 from a 'call'
    4376 or 'invoke' instruction that returns multiple
    4377 results.

    4378
    4379
    Arguments:
    4380
    4381

    The 'getresult' instruction takes a call or invoke value as its

    4382 first argument, or an undef value. The value must have
    4383 href="#t_struct">structure type. The second argument is a constant
    4384 unsigned index value which must be in range for the number of values returned
    4385 by the call.

    4386
    4387
    Semantics:
    4388
    4389

    The 'getresult' instruction extracts the element identified by

    4390 'index' from the aggregate value.

    4391
    4392
    Example:
    4393
    4394
    
                      
                    
    4395 %struct.A = type { i32, i8 }
    4396
    4397 %r = call %struct.A @foo()
    4398 %gr = getresult %struct.A %r, 0 ; yields i32:%gr
    4399 %gr1 = getresult %struct.A %r, 1 ; yields i8:%gr1
    4400 add i32 %gr, 42
    4401 add i8 %gr1, 41
    4402
    44034353
    44044354
    44054355