Skip to content

Riscv snitch

riscv_snitch

RiscvSnitchFunctions dataclass

Bases: InterpreterFunctions

Source code in xdsl/interpreters/riscv_snitch.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@register_impls
@dataclass
class RiscvSnitchFunctions(InterpreterFunctions):
    @impl(riscv_snitch.FrepOuterOp)
    def run_frep_outer(
        self,
        interpreter: Interpreter,
        op: riscv_snitch.FrepOuterOp,
        args: tuple[Any, ...],
    ):
        args = RiscvFunctions.get_reg_values(interpreter, op.operands, args)
        count_minus_one, *loop_args = args
        loop_args = tuple(loop_args)

        for _ in range(count_minus_one + 1):
            loop_args = interpreter.run_ssacfg_region(op.body, loop_args, "frep.o")

        return loop_args

    @impl_terminator(riscv_snitch.FrepYieldOp)
    def run_yield(
        self,
        interpreter: Interpreter,
        op: riscv_snitch.FrepYieldOp,
        args: tuple[Any, ...],
    ):
        return ReturnedValues(args), ()

    @impl(riscv_snitch.ReadOp)
    def run_read(
        self,
        interpreter: Interpreter,
        op: riscv_snitch.ReadOp,
        args: tuple[Any, ...],
    ):
        (stream,) = args
        stream: StridedPointerInputStream = stream

        value = stream.read()

        RiscvFunctions.set_reg_value(interpreter, op.res.type, value)

        return (value,)

    @impl(riscv_snitch.WriteOp)
    def run_write(
        self,
        interpreter: Interpreter,
        op: riscv_snitch.WriteOp,
        args: tuple[Any, ...],
    ):
        value, stream = args

        value = RiscvFunctions.get_reg_value(interpreter, op.value.type, value)

        stream.write(value)

        return ()

__init__() -> None

run_frep_outer(interpreter: Interpreter, op: riscv_snitch.FrepOuterOp, args: tuple[Any, ...])

Source code in xdsl/interpreters/riscv_snitch.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@impl(riscv_snitch.FrepOuterOp)
def run_frep_outer(
    self,
    interpreter: Interpreter,
    op: riscv_snitch.FrepOuterOp,
    args: tuple[Any, ...],
):
    args = RiscvFunctions.get_reg_values(interpreter, op.operands, args)
    count_minus_one, *loop_args = args
    loop_args = tuple(loop_args)

    for _ in range(count_minus_one + 1):
        loop_args = interpreter.run_ssacfg_region(op.body, loop_args, "frep.o")

    return loop_args

run_yield(interpreter: Interpreter, op: riscv_snitch.FrepYieldOp, args: tuple[Any, ...])

Source code in xdsl/interpreters/riscv_snitch.py
36
37
38
39
40
41
42
43
@impl_terminator(riscv_snitch.FrepYieldOp)
def run_yield(
    self,
    interpreter: Interpreter,
    op: riscv_snitch.FrepYieldOp,
    args: tuple[Any, ...],
):
    return ReturnedValues(args), ()

run_read(interpreter: Interpreter, op: riscv_snitch.ReadOp, args: tuple[Any, ...])

Source code in xdsl/interpreters/riscv_snitch.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@impl(riscv_snitch.ReadOp)
def run_read(
    self,
    interpreter: Interpreter,
    op: riscv_snitch.ReadOp,
    args: tuple[Any, ...],
):
    (stream,) = args
    stream: StridedPointerInputStream = stream

    value = stream.read()

    RiscvFunctions.set_reg_value(interpreter, op.res.type, value)

    return (value,)

run_write(interpreter: Interpreter, op: riscv_snitch.WriteOp, args: tuple[Any, ...])

Source code in xdsl/interpreters/riscv_snitch.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@impl(riscv_snitch.WriteOp)
def run_write(
    self,
    interpreter: Interpreter,
    op: riscv_snitch.WriteOp,
    args: tuple[Any, ...],
):
    value, stream = args

    value = RiscvFunctions.get_reg_value(interpreter, op.value.type, value)

    stream.write(value)

    return ()