Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dialects: (arith) add missing sitofp and fptoui ops #3784

Open
erick-xanadu opened this issue Jan 23, 2025 · 2 comments
Open

dialects: (arith) add missing sitofp and fptoui ops #3784

erick-xanadu opened this issue Jan 23, 2025 · 2 comments
Labels
dialects Changes on the dialects

Comments

@erick-xanadu
Copy link

erick-xanadu commented Jan 23, 2025

Hello, I will try to contribute the following items to xDSL, but I've been a bit busy. I'll add them here in case I take too long and you folks would like to add it to the repository. I think I agree with the comment made by @superlopuh in Zulip that the interpreter should use typed values instead of python ones. I'll try to find some time to work on that as well.

@irdl.irdl_op_definition
class UIToFPOp(irdl.IRDLOperation):
    name = "arith.sitofp"

    input = irdl.operand_def(builtin.IntegerType)
    result = irdl.result_def(builtin.AnyFloatConstr)

    assembly_format = "$input attr-dict `:` type($input) `to` type($result)"

    traits = irdl.traits_def(traits.Pure())

    def __init__(self, op: ir.SSAValue | ir.Operation, target_type: builtin.AnyFloat):
        super().__init__(operands=[op], result_types=[target_type])

@irdl.irdl_op_definition
class FPToUIOp(irdl.IRDLOperation):
    name = "arith.fptoui"

    input = irdl.operand_def(builtin.AnyFloatConstr)
    result = irdl.result_def(builtin.IntegerType)

    assembly_format = "$input attr-dict `:` type($input) `to` type($result)"

    traits = irdl.traits_def(traits.Pure())

    def __init__(self, op: ir.SSAValue | ir.Operation, target_type: builtin.IntegerType):
        super().__init__(operands=[op], result_types=[target_type])
@superlopuh
Copy link
Member

Fantastic, thank you! I look forward to your PRs :)

@superlopuh superlopuh changed the title A couple of missing things dialects: (arith) add missing sitofp and fptoui ops Feb 11, 2025
@compor compor added dialects Changes on the dialects interpreter xDSL Interpreter labels Feb 14, 2025
@compor
Copy link
Collaborator

compor commented Feb 14, 2025

I'm going to split this issue in two more, just to track this a bit better.

@compor compor removed the interpreter xDSL Interpreter label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects
Projects
None yet
Development

No branches or pull requests

3 participants