{"id":24849,"library":"xdsl","title":"xDSL","description":"xDSL is a Python library for defining and manipulating domain-specific languages (DSLs) with a focus on compiler infrastructure. It provides IR building blocks, pattern rewrites, and verification passes. Current version: 0.63.0. Released monthly.","status":"active","version":"0.63.0","language":"python","source_language":"en","source_url":"https://github.com/xdslproject/xdsl","tags":["DSL","compiler","MLIR","rewriting","IR"],"install":[{"cmd":"pip install xdsl","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"Top-level imports are not available; use xdsl.ir submodule.","wrong":"from xdsl import Block","symbol":"IR builtins","correct":"from xdsl.ir import Block, Region, Operation, SSAValue"},{"note":"MLIR converter moved to xdsl.interpreters.mlir.","wrong":"from xdsl.mlir import MLIRConverter","symbol":"MLIR type conversion (legacy)","correct":"from xdsl.interpreters.mlir import MLIRConverter"}],"quickstart":{"code":"from xdsl.ir import Block, Region, Operation, SSAValue\nfrom xdsl.dialects.builtin import ModuleOp, IntegerType, FunctionType\nfrom xdsl.dialects import arith, func\n\n# Create a simple function: i32 add\nint32 = IntegerType(32)\nfunc_type = FunctionType.from_lists([int32, int32], [int32])\n\n# Build region with add operation\nblock = Block.from_ops([\n    arith.Addi(SSAValue(0), SSAValue(1)),\n    func.Return()\n])\nregion = Region(block)\n\n# Wrap in FunctionOp\nfunc_op = func.FuncOp(\"add\", func_type, region)\nmodule = ModuleOp([func_op])\nprint(module)\n","lang":"python","description":"Construct an MLIR-like module with a function containing an add operation."},"warnings":[{"fix":"Use Block.from_ops() with SSAValue references and explicit operands. See migration guide.","message":"In version 0.60.0, the entire IR API was refactored. Operations now require explicit operands and results; the old mutable operation pattern is removed.","severity":"breaking","affected_versions":"<0.60.0 => >=0.60.0"},{"fix":"Replace xdsl.util imports with xdsl.utils equivalents.","message":"The xdsl.util module is deprecated; use xdsl.utils or xdsl.ir utilities instead.","severity":"deprecated","affected_versions":">=0.60.0"},{"fix":"Ensure block arguments are defined first, then use SSAValue(index) where index corresponds to the argument list order.","message":"SSAValue indices are positional and must match the block's arguments. A common mistake is to assume SSAValue(0) refers to the first operation's result; it refers to the first block argument.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from xdsl.ir import Block, Region, Operation, SSAValue`.","cause":"Import path is wrong; the package does not expose submodules at top level.","error":"AttributeError: module 'xdsl' has no attribute 'ir'"},{"fix":"Pass operands and result_types when constructing an operation: `arith.Addi(operands=[...], result_types=[...])` or use helper methods.","cause":"Creating an operation without specifying operands and results in the new API (post 0.60).","error":"ValueError: Operation must have at least one operand or result"},{"fix":"Use `Block.from_ops([op1, op2])` or `Block(ops=[op1, op2])` keyword argument.","cause":"Block no longer accepts operations as positional arguments in newer versions.","error":"TypeError: cannot instantiate 'Block' with positional arguments"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}