Skip to content

Commit

Permalink
interpreter: (riscv) add fmadd.d interpreter function (#3720)
Browse files Browse the repository at this point in the history
  • Loading branch information
superlopuh authored Jan 8, 2025
1 parent 0d01d47 commit 3c3b445
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/interpreters/test_riscv_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ def my_custom_instruction(

# D extension arithmetic

assert interpreter.run_op(
riscv.FMAddDOp(
TestSSAValue(fregister),
TestSSAValue(fregister),
TestSSAValue(fregister),
rd=riscv.FloatRegisterType.unallocated(),
),
(3.0, 4.0, 5.0),
) == (17.0,)

assert interpreter.run_op(
riscv.FAddDOp(
TestSSAValue(fregister),
Expand Down
11 changes: 11 additions & 0 deletions xdsl/interpreters/riscv.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,17 @@ def run_fmv(

# region D extension

@impl(riscv.FMAddDOp)
def run_fmadd_d(
self,
interpreter: Interpreter,
op: riscv.FMAddDOp,
args: tuple[Any, ...],
):
args = RiscvFunctions.get_reg_values(interpreter, op.operands, args)
results = (args[0] * args[1] + args[2],)
return RiscvFunctions.set_reg_values(interpreter, op.results, results)

@impl(riscv.FAddDOp)
def run_fadd_d(
self,
Expand Down

0 comments on commit 3c3b445

Please sign in to comment.