From a517988cead01a4f4c893f83c403f111b30c2cd5 Mon Sep 17 00:00:00 2001 From: Sasha Lopoukhine Date: Thu, 23 Nov 2023 12:06:11 +0000 Subject: [PATCH] dialects: (riscv) add ability to fld from label (#1797) Will file some issues to add this to the rest of the fld/fsd ops --- .../dialects/riscv/riscv_assembly_emission.mlir | 4 ++++ xdsl/dialects/riscv.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/filecheck/dialects/riscv/riscv_assembly_emission.mlir b/tests/filecheck/dialects/riscv/riscv_assembly_emission.mlir index f330ab4eef..6371a6bd9d 100644 --- a/tests/filecheck/dialects/riscv/riscv_assembly_emission.mlir +++ b/tests/filecheck/dialects/riscv/riscv_assembly_emission.mlir @@ -254,6 +254,10 @@ %fld = riscv.fld %0, 1 : (!riscv.reg) -> !riscv.freg // CHECK-NEXT: fld j8, 1(zero) + + %min_val = riscv.fld %0, "hello" : (!riscv.reg) -> !riscv.freg + // CHECK-NEXT: fld j8, hello, zero + riscv.fsd %0, %f0, 1 : (!riscv.reg, !riscv.freg) -> () // CHECK-NEXT: fsd j5, 1(zero) diff --git a/xdsl/dialects/riscv.py b/xdsl/dialects/riscv.py index d62dd64de6..8a80f62928 100644 --- a/xdsl/dialects/riscv.py +++ b/xdsl/dialects/riscv.py @@ -3532,9 +3532,14 @@ def assembly_line(self) -> str | None: value = _assembly_arg_str(self.rd) imm = _assembly_arg_str(self.immediate) offset = _assembly_arg_str(self.rs1) - return _assembly_line( - instruction_name, f"{value}, {imm}({offset})", self.comment - ) + if isinstance(self.immediate, LabelAttr): + return _assembly_line( + instruction_name, f"{value}, {imm}, {offset}", self.comment + ) + else: + return _assembly_line( + instruction_name, f"{value}, {imm}({offset})", self.comment + ) class FSdOpHasCanonicalizationPatternTrait(HasCanonicalisationPatternsTrait):