Skip to content

Func

func

FuncFunctions dataclass

Bases: InterpreterFunctions

Source code in xdsl/interpreters/func.py
@register_impls
class FuncFunctions(InterpreterFunctions):
    @impl_terminator(func.ReturnOp)
    def run_return(
        self, interpreter: Interpreter, op: func.ReturnOp, args: tuple[Any, ...]
    ) -> tuple[TerminatorValue, PythonValues]:
        return ReturnedValues(args), ()

    @impl(func.CallOp)
    def run_call(
        self, interpreter: Interpreter, op: func.CallOp, args: tuple[Any, ...]
    ) -> tuple[Any, ...]:
        return interpreter.call_op(op.callee, args)

    @impl_callable(func.FuncOp)
    def call_func(
        self, interpreter: Interpreter, op: func.FuncOp, args: tuple[Any, ...]
    ):
        if (first_block := op.body.blocks.first) is None or not first_block.ops:
            return interpreter.call_external(op.sym_name.data, op, args)
        else:
            return interpreter.run_ssacfg_region(op.body, args, op.sym_name.data)

run_return(interpreter: Interpreter, op: func.ReturnOp, args: tuple[Any, ...]) -> tuple[TerminatorValue, PythonValues]

Source code in xdsl/interpreters/func.py
@impl_terminator(func.ReturnOp)
def run_return(
    self, interpreter: Interpreter, op: func.ReturnOp, args: tuple[Any, ...]
) -> tuple[TerminatorValue, PythonValues]:
    return ReturnedValues(args), ()

run_call(interpreter: Interpreter, op: func.CallOp, args: tuple[Any, ...]) -> tuple[Any, ...]

Source code in xdsl/interpreters/func.py
@impl(func.CallOp)
def run_call(
    self, interpreter: Interpreter, op: func.CallOp, args: tuple[Any, ...]
) -> tuple[Any, ...]:
    return interpreter.call_op(op.callee, args)

call_func(interpreter: Interpreter, op: func.FuncOp, args: tuple[Any, ...])

Source code in xdsl/interpreters/func.py
@impl_callable(func.FuncOp)
def call_func(
    self, interpreter: Interpreter, op: func.FuncOp, args: tuple[Any, ...]
):
    if (first_block := op.body.blocks.first) is None or not first_block.ops:
        return interpreter.call_external(op.sym_name.data, op, args)
    else:
        return interpreter.run_ssacfg_region(op.body, args, op.sym_name.data)