Define a return instruction.

It is possible to return multiple values from a function, so ReturnData contains
a VariableArgs instance.

We don't want return instructions to appear as 'return (v1)', so tweak the
printing of VariableArgs so the parantheses are added externally.
This commit is contained in:
Jakob Stoklund Olesen
2016-07-08 16:19:26 -07:00
parent a39e418d32
commit 520a438c42
7 changed files with 61 additions and 21 deletions

View File

@@ -95,6 +95,18 @@ trapnz = Instruction(
""",
ins=c)
rvals = Operand('rvals', variable_args, doc='return values')
x_return = Instruction(
'return', r"""
Return from the function.
Unconditionally transfer control to the calling function, passing the
provided return values. The list of return values must match the
function signature's return types.
""",
ins=rvals)
#
# Materializing constants.
#

View File

@@ -43,6 +43,8 @@ BranchTable = InstructionFormat(value, jump_table)
Call = InstructionFormat(
function, variable_args, multiple_results=True, boxed_storage=True)
Return = InstructionFormat(variable_args, boxed_storage=True)
# Finally extract the names of global variables in this module.
InstructionFormat.extract_names(globals())