Skip to content

Cf

cf

CfFunctions dataclass

Bases: InterpreterFunctions

Source code in xdsl/interpreters/cf.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@register_impls
class CfFunctions(InterpreterFunctions):
    @impl_terminator(cf.BranchOp)
    def run_br(self, interpreter: Interpreter, op: cf.BranchOp, args: tuple[Any, ...]):
        return Successor(op.successor, args), ()

    @impl_terminator(cf.ConditionalBranchOp)
    def run_cond_br(
        self,
        interpreter: Interpreter,
        op: cf.ConditionalBranchOp,
        args: tuple[Any, ...],
    ):
        cond: int = args[0]
        if cond:
            block_args = interpreter.get_values(op.then_arguments)
            return Successor(op.then_block, block_args), ()
        else:
            block_args = interpreter.get_values(op.else_arguments)
            return Successor(op.else_block, block_args), ()

run_br(interpreter: Interpreter, op: cf.BranchOp, args: tuple[Any, ...])

Source code in xdsl/interpreters/cf.py
15
16
17
@impl_terminator(cf.BranchOp)
def run_br(self, interpreter: Interpreter, op: cf.BranchOp, args: tuple[Any, ...]):
    return Successor(op.successor, args), ()

run_cond_br(interpreter: Interpreter, op: cf.ConditionalBranchOp, args: tuple[Any, ...])

Source code in xdsl/interpreters/cf.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@impl_terminator(cf.ConditionalBranchOp)
def run_cond_br(
    self,
    interpreter: Interpreter,
    op: cf.ConditionalBranchOp,
    args: tuple[Any, ...],
):
    cond: int = args[0]
    if cond:
        block_args = interpreter.get_values(op.then_arguments)
        return Successor(op.then_block, block_args), ()
    else:
        block_args = interpreter.get_values(op.else_arguments)
        return Successor(op.else_block, block_args), ()