From b1b8e790b6ecf3b819b9a1fec03ce729fb059c01 Mon Sep 17 00:00:00 2001 From: Sasha Lopoukhine Date: Tue, 17 Sep 2024 14:08:05 +0100 Subject: [PATCH] misc: remove redundant `AnyAttr()` constraints from op definitions [NFC] (#3181) --- docs/Toy/toy/dialects/toy.py | 5 ++--- tests/test_parser_error.py | 5 ++--- xdsl/dialects/affine.py | 5 ++--- xdsl/dialects/experimental/aie.py | 3 +-- xdsl/dialects/experimental/air.py | 14 ++++++-------- xdsl/dialects/experimental/hls.py | 7 +++---- xdsl/dialects/fsm.py | 11 +++++------ xdsl/dialects/hw.py | 3 +-- xdsl/dialects/vector.py | 5 ++--- xdsl/frontend/symref.py | 5 ++--- 10 files changed, 26 insertions(+), 37 deletions(-) diff --git a/docs/Toy/toy/dialects/toy.py b/docs/Toy/toy/dialects/toy.py index 75ed3b683a..88f9951920 100644 --- a/docs/Toy/toy/dialects/toy.py +++ b/docs/Toy/toy/dialects/toy.py @@ -19,7 +19,6 @@ ) from xdsl.ir import Attribute, Block, Dialect, Operation, OpResult, Region, SSAValue from xdsl.irdl import ( - AnyAttr, IRDLOperation, attr_def, base, @@ -265,7 +264,7 @@ def verify_(self): @irdl_op_definition class GenericCallOp(IRDLOperation): name = "toy.generic_call" - arguments = var_operand_def(AnyAttr()) + arguments = var_operand_def() callee = attr_def(SymbolRefAttr) # Note: naming this results triggers an ArgumentError @@ -351,7 +350,7 @@ class PrintOp(IRDLOperation): """ name = "toy.print" - input = operand_def(AnyAttr()) + input = operand_def() def __init__(self, input: SSAValue): return super().__init__(operands=[input]) diff --git a/tests/test_parser_error.py b/tests/test_parser_error.py index 650b010365..3c23924b09 100644 --- a/tests/test_parser_error.py +++ b/tests/test_parser_error.py @@ -2,7 +2,6 @@ from xdsl.context import MLContext from xdsl.irdl import ( - AnyAttr, IRDLOperation, irdl_op_definition, var_operand_def, @@ -15,8 +14,8 @@ @irdl_op_definition class UnknownOp(IRDLOperation): name = "test.unknown" - ops = var_operand_def(AnyAttr()) - res = var_result_def(AnyAttr()) + ops = var_operand_def() + res = var_result_def() def check_error(prog: str, line: int, column: int, message: str): diff --git a/xdsl/dialects/affine.py b/xdsl/dialects/affine.py index 69dc11517b..752cfabae6 100644 --- a/xdsl/dialects/affine.py +++ b/xdsl/dialects/affine.py @@ -20,7 +20,6 @@ from xdsl.ir import Attribute, Block, Dialect, Operation, Region, SSAValue from xdsl.ir.affine import AffineExpr, AffineMap from xdsl.irdl import ( - AnyAttr, AttrSizedOperandSegments, ConstraintVar, IRDLOperation, @@ -116,7 +115,7 @@ class For(IRDLOperation): lowerBoundOperands = var_operand_def(IndexType) upperBoundOperands = var_operand_def(IndexType) inits = var_operand_def() - res = var_result_def(AnyAttr()) + res = var_result_def() lowerBoundMap = prop_def(AffineMapAttr) upperBoundMap = prop_def(AffineMapAttr) @@ -353,7 +352,7 @@ def verify_(self) -> None: @irdl_op_definition class Yield(IRDLOperation): name = "affine.yield" - arguments = var_operand_def(AnyAttr()) + arguments = var_operand_def() traits = frozenset([IsTerminator(), Pure()]) diff --git a/xdsl/dialects/experimental/aie.py b/xdsl/dialects/experimental/aie.py index 2c6abb1f9d..59b7c75e20 100644 --- a/xdsl/dialects/experimental/aie.py +++ b/xdsl/dialects/experimental/aie.py @@ -14,7 +14,6 @@ from xdsl.dialects import memref from xdsl.dialects.builtin import ( I32, - AnyAttr, AnyIntegerAttr, ArrayAttr, Block, @@ -611,7 +610,7 @@ def parse(cls, parser: Parser) -> DMAStartOp: @irdl_op_definition class DebugOp(IRDLOperation): name = "aie.debug" - arg = operand_def(AnyAttr()) + arg = operand_def() def __init__(self, arg: Operation | SSAValue): super().__init__(operands=[arg]) diff --git a/xdsl/dialects/experimental/air.py b/xdsl/dialects/experimental/air.py index a2ddc7c91b..6eceb2d673 100644 --- a/xdsl/dialects/experimental/air.py +++ b/xdsl/dialects/experimental/air.py @@ -31,7 +31,6 @@ TypeAttribute, ) from xdsl.irdl import ( - AnyAttr, AttrSizedOperandSegments, IRDLOperation, ParsePropInAttrDict, @@ -333,9 +332,8 @@ def parse(cls, parser: Parser) -> ExecuteOp: class ExecuteTerminatorOp(IRDLOperation): name = "air.execute_terminator" - results_op = var_operand_def( - AnyAttr() - ) # even though this is an operand they decided to name it "result" in the original specification + # even though this is an operand they decided to name it "result" in the original specification + results_op = var_operand_def() traits = frozenset([HasParent(ExecuteOp), IsTerminator()]) @@ -369,7 +367,7 @@ class HerdOp(IRDLOperation): sym_name = opt_prop_def(StringAttr) async_dependencies = var_operand_def(AsyncTokenAttr()) sizes = var_operand_def(IndexType()) - herd_operands = var_operand_def(AnyAttr()) + herd_operands = var_operand_def() async_token = opt_result_def(AsyncTokenAttr) region = opt_region_def() @@ -517,7 +515,7 @@ class LaunchOp(IRDLOperation): sym_name = opt_prop_def(StringAttr) async_dependencies = var_operand_def(AsyncTokenAttr()) sizes = var_operand_def(IndexType()) - launch_operands = var_operand_def(AnyAttr()) + launch_operands = var_operand_def() async_token = result_def(AsyncTokenAttr) body = opt_region_def() @@ -674,7 +672,7 @@ class PipelineStageOp(IRDLOperation): name = "air.pipeline.stage" opers = var_operand_def(Attribute) - result = var_result_def(AnyAttr()) + result = var_result_def() body = opt_region_def() @@ -751,7 +749,7 @@ class SegmentOp(IRDLOperation): sym_name = opt_prop_def(StringAttr) async_dependencies = var_operand_def(AsyncTokenAttr()) sizes = var_operand_def(IndexType()) - segment_operands = var_operand_def(AnyAttr()) + segment_operands = var_operand_def() async_token = result_def(AsyncTokenAttr) body = opt_region_def() diff --git a/xdsl/dialects/experimental/hls.py b/xdsl/dialects/experimental/hls.py index 53f3bc21a3..cf202c905a 100644 --- a/xdsl/dialects/experimental/hls.py +++ b/xdsl/dialects/experimental/hls.py @@ -9,7 +9,6 @@ ) from xdsl.ir import Dialect, Operation, Region, SSAValue, TypeAttribute from xdsl.irdl import ( - AnyAttr, IRDLOperation, ParameterDef, attr_def, @@ -27,7 +26,7 @@ @irdl_op_definition class HLSYield(IRDLOperation): name = "hls.yield" - arguments = var_operand_def(AnyAttr()) + arguments = var_operand_def() traits = frozenset([IsTerminator()]) @@ -115,7 +114,7 @@ def get(elem_type: Attribute) -> HLSStream: @irdl_op_definition class HLSStreamWrite(IRDLOperation): name = "hls.write" - element = operand_def(AnyAttr()) + element = operand_def() stream = operand_def(HLSStreamType) def __init__(self, element: SSAValue | Operation, stream: SSAValue | Operation): @@ -126,7 +125,7 @@ def __init__(self, element: SSAValue | Operation, stream: SSAValue | Operation): class HLSStreamRead(IRDLOperation): name = "hls.read" stream = operand_def(HLSStreamType) - res = result_def(AnyAttr()) + res = result_def() def __init__(self, stream: SSAValue): assert isinstance(stream.type, HLSStreamType) diff --git a/xdsl/dialects/fsm.py b/xdsl/dialects/fsm.py index c92a453c4d..5c54209748 100644 --- a/xdsl/dialects/fsm.py +++ b/xdsl/dialects/fsm.py @@ -23,7 +23,6 @@ TypeAttribute, ) from xdsl.irdl import ( - AnyAttr, IRDLOperation, attr_def, irdl_attr_definition, @@ -186,7 +185,7 @@ class OutputOp(IRDLOperation): name = "fsm.output" - operand = var_operand_def(AnyAttr()) + operand = var_operand_def() traits = frozenset([IsTerminator(), HasParent(StateOp)]) @@ -412,11 +411,11 @@ class TriggerOp(IRDLOperation): name = "fsm.trigger" - inputs = var_operand_def(AnyAttr()) + inputs = var_operand_def() instance = operand_def(InstanceType) - outputs = var_result_def(AnyAttr()) + outputs = var_result_def() def __init__( self, @@ -464,11 +463,11 @@ class HWInstanceOp(IRDLOperation): sym_name = attr_def(StringAttr) machine = attr_def(FlatSymbolRefAttrConstr) - inputs = var_operand_def(AnyAttr()) + inputs = var_operand_def() clock = operand_def(signlessIntegerLike) reset = operand_def(signlessIntegerLike) - outputs = var_result_def(AnyAttr()) + outputs = var_result_def() def __init__( self, diff --git a/xdsl/dialects/hw.py b/xdsl/dialects/hw.py index 472e99be72..9b4f7b5f9f 100644 --- a/xdsl/dialects/hw.py +++ b/xdsl/dialects/hw.py @@ -34,7 +34,6 @@ TypeAttribute, ) from xdsl.irdl import ( - AnyAttr, IRDLOperation, SingleBlockRegion, attr_def, @@ -1243,7 +1242,7 @@ def print_output_port(name: str, port_type: Attribute): class OutputOp(IRDLOperation): name = "hw.output" - inputs = var_operand_def(AnyAttr()) + inputs = var_operand_def() traits = frozenset([IsTerminator(), HasParent(HWModuleOp)]) diff --git a/xdsl/dialects/vector.py b/xdsl/dialects/vector.py index f4be7b2e92..eedb184926 100644 --- a/xdsl/dialects/vector.py +++ b/xdsl/dialects/vector.py @@ -13,7 +13,6 @@ ) from xdsl.ir import Attribute, Dialect, Operation, SSAValue from xdsl.irdl import ( - AnyAttr, IRDLOperation, irdl_op_definition, operand_def, @@ -86,7 +85,7 @@ def get( @irdl_op_definition class Broadcast(IRDLOperation): name = "vector.broadcast" - source = operand_def(AnyAttr()) + source = operand_def() vector = result_def(VectorType) traits = frozenset((Pure(),)) @@ -262,7 +261,7 @@ def get( @irdl_op_definition class Print(IRDLOperation): name = "vector.print" - source = operand_def(AnyAttr()) + source = operand_def() @staticmethod def get(source: Operation | SSAValue) -> Print: diff --git a/xdsl/frontend/symref.py b/xdsl/frontend/symref.py index 11066686b4..bb8d1d6cca 100644 --- a/xdsl/frontend/symref.py +++ b/xdsl/frontend/symref.py @@ -3,7 +3,6 @@ from xdsl.dialects.builtin import StringAttr, SymbolRefAttr from xdsl.ir import Attribute, Dialect, Operation, SSAValue from xdsl.irdl import ( - AnyAttr, IRDLOperation, attr_def, irdl_op_definition, @@ -27,7 +26,7 @@ def get(sym_name: str | StringAttr) -> Declare: @irdl_op_definition class Fetch(IRDLOperation): name = "symref.fetch" - value = result_def(AnyAttr()) + value = result_def() symbol = attr_def(SymbolRefAttr) @staticmethod @@ -40,7 +39,7 @@ def get(symbol: str | SymbolRefAttr, result_type: Attribute) -> Fetch: @irdl_op_definition class Update(IRDLOperation): name = "symref.update" - value = operand_def(AnyAttr()) + value = operand_def() symbol = attr_def(SymbolRefAttr) @staticmethod