Skip to content

Commit

Permalink
dialects: (riscv) add ability to fld from label (#1797)
Browse files Browse the repository at this point in the history
Will file some issues to add this to the rest of the fld/fsd ops
  • Loading branch information
superlopuh authored Nov 23, 2023
1 parent 3fe2047 commit a517988
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions tests/filecheck/dialects/riscv/riscv_assembly_emission.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@

%fld = riscv.fld %0, 1 : (!riscv.reg<zero>) -> !riscv.freg<j8>
// CHECK-NEXT: fld j8, 1(zero)

%min_val = riscv.fld %0, "hello" : (!riscv.reg<zero>) -> !riscv.freg<j8>
// CHECK-NEXT: fld j8, hello, zero

riscv.fsd %0, %f0, 1 : (!riscv.reg<zero>, !riscv.freg<j5>) -> ()
// CHECK-NEXT: fsd j5, 1(zero)

Expand Down
11 changes: 8 additions & 3 deletions xdsl/dialects/riscv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a517988

Please sign in to comment.