llvm.org GIT mirror llvm / f4cde4e
fix description of 'ret' to be more correct with multiple return values. Clarify that it is impossible to 'multiply return' a struct with zero elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50131 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
1 changed file(s) with 33 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
12221222
12231223
12241224
1225
Overview:
1225
1226
Overview:
1227
12261228

The function type can be thought of as a function signature. It

12271229 consists of a return type and a list of formal parameter types. The
1228 return type of a function type is a scalar type or a void type or a struct type.
1230 return type of a function type is a scalar type, a void type, or a struct type.
12291231 If the return type is a struct type then all struct elements must be of first
1230 class types. Function types are usually used to build virtual function tables
1231 (which are structures of pointers to functions), for indirect function
1232 calls, and when defining a function.

1233
1234
Syntax:
1235
  <returntype list> (<parameter list>)
>
1232 class types, and the struct must have at least one element.>
1233
1234
Syntax:
1235
1236

                  
                
1237 <returntype list> (<parameter list>)
1238
1239
12361240

...where '<parameter list>' is a comma-separated list of type

12371241 specifiers. Optionally, the parameter list may include a type ...,
12381242 which indicates that the function takes a variable number of arguments.
12401244 href="#int_varargs">variable argument handling intrinsic functions.
12411245 '<returntype list>' is a comma-separated list of
12421246 first class type specifiers.

1247
12431248
Examples:
12441249
12451250
18011806 ret void ; Return from void function
18021807 ret <type> <value>, <type> <value> ; Return two values from a non-void function
18031808
1804
Overview:
1809
1810
Overview:
1811
18051812

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

18061813 value) from a function back to the caller.

18071814

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

1808 returns a value and then causes control flow, and one that just causes
1815 returns value(s) and then causes control flow, and one that just causes
18091816 control flow to occur.

1810
Arguments:
1811

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

1812 type of each return value must be a 'first class'
1813 type. Note that a function is not well formed
1814 if there exists a 'ret' instruction inside of the function that
1815 returns values that do not match the return type of the function.

1816
Semantics:
1817
1818
Arguments:
1819
1820

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

1821 The type of each return value must be a 'first
1822 class' type. Note that a function is not well
1823 formed if there exists a 'ret' instruction inside of the
1824 function that returns values that do not match the return type of the
1825 function.

1826
1827
Semantics:
1828
18171829

When the 'ret' instruction is executed, control flow

18181830 returns back to the calling function's context. If the caller is a "
18191831 href="#i_call">call" instruction, execution continues at
18241836 return value. If the instruction returns multiple values then these
18251837 values can only be accessed through a 'getresult
18261838 ' instruction.

1839
18271840
Example:
1828
  ret i32 5                       ; Return an integer value of 5
                  
                
1841
1842

                  
                
1843 ret i32 5 ; Return an integer value of 5
18291844 ret void ; Return from a void function
18301845 ret i32 4, i8 2 ; Return two values 4 and 2
18311846