diff --git a/xdsl/dialects/riscv_func.py b/xdsl/dialects/riscv_func.py index d9e8a63704..b45ef90794 100644 --- a/xdsl/dialects/riscv_func.py +++ b/xdsl/dialects/riscv_func.py @@ -1,7 +1,6 @@ from __future__ import annotations from collections.abc import Sequence -from typing import cast from xdsl.dialects import riscv from xdsl.dialects.builtin import ( @@ -13,9 +12,7 @@ SymbolRefAttr, ) from xdsl.dialects.utils import ( - parse_call_op_like, parse_func_op_like, - print_call_op_like, print_func_op_like, ) from xdsl.ir import Attribute, Dialect, Operation, Region, SSAValue @@ -83,6 +80,10 @@ class CallOp(riscv.RISCVInstruction): callee = attr_def(SymbolRefAttr) ress = var_result_def(riscv.RISCVRegisterType) + assembly_format = ( + "$callee `(` $args `)` attr-dict `:` functional-type($args, $ress)" + ) + def __init__( self, callee: SymbolRefAttr, @@ -110,27 +111,6 @@ def verify_(self): f"Function op has too many results ({len(self.results)}), expected fewer than 3" ) - def print(self, printer: Printer): - print_call_op_like( - printer, - self, - self.callee, - self.args, - self.attributes, - reserved_attr_names=("callee",), - ) - - @classmethod - def parse(cls, parser: Parser) -> CallOp: - callee, arguments, results, extra_attributes = parse_call_op_like( - parser, reserved_attr_names=("callee",) - ) - ress = cast(tuple[riscv.RISCVRegisterType, ...], results) - call = CallOp(callee, arguments, ress) - if extra_attributes is not None: - call.attributes |= extra_attributes.data - return call - def assembly_instruction_name(self) -> str: return "jal" diff --git a/xdsl/dialects/utils/format.py b/xdsl/dialects/utils/format.py index ae7965d213..8c4d7074dd 100644 --- a/xdsl/dialects/utils/format.py +++ b/xdsl/dialects/utils/format.py @@ -7,7 +7,6 @@ DictionaryAttr, FunctionType, StringAttr, - SymbolRefAttr, ) from xdsl.ir import ( Attribute, @@ -22,49 +21,6 @@ from xdsl.printer import Printer -def print_call_op_like( - printer: Printer, - op: Operation, - callee: SymbolRefAttr, - args: Sequence[SSAValue], - attributes: dict[str, Attribute], - *, - reserved_attr_names: Sequence[str], -): - printer.print_string(" ") - printer.print_attribute(callee) - printer.print_string("(") - printer.print_list(args, printer.print_ssa_value) - printer.print_string(")") - printer.print_op_attributes(attributes, reserved_attr_names=reserved_attr_names) - printer.print_string(" : ") - printer.print_operation_type(op) - - -def parse_call_op_like( - parser: Parser, *, reserved_attr_names: Sequence[str] -) -> tuple[ - SymbolRefAttr, Sequence[SSAValue], Sequence[Attribute], DictionaryAttr | None -]: - callee = parser.parse_symbol_name() - unresolved_arguments = parser.parse_op_args_list() - extra_attributes = parser.parse_optional_attr_dict_with_reserved_attr_names( - reserved_attr_names - ) - parser.parse_characters(":") - pos = parser.pos - function_type = parser.parse_function_type() - arguments = parser.resolve_operands( - unresolved_arguments, function_type.inputs.data, pos - ) - return ( - SymbolRefAttr(callee), - arguments, - function_type.outputs.data, - extra_attributes, - ) - - class AbstractYieldOperation(Generic[AttributeInvT], IRDLOperation): """ A base class for yielding operations to inherit, provides the standard custom syntax