619 Commits

Author SHA1 Message Date
Twice
1503293cbc
[MLIR][Python] Support has_trait for operations (#188492)
This PR adds a `has_trait(trait_cls)` API to `_OperationBase`, that can
be used for:
- C++-defined operations and C++-defined traits (e.g.
`func_return_op.has_trait(IsTerminatorTrait)`)
- Python-defined operations and C++-defined traits (e.g.
`my_python_op.has_trait(IsTerminatorTrait)`)
- Python-defined operations and Python-defined traits (e.g.
`my_python_op.has_trait(MyPythonTrait)`)

---------

Co-authored-by: Maksim Levental <maksim.levental@gmail.com>
2026-03-27 00:02:31 +08:00
Sergei Lebedev
2c0e63c9b6
[MLIR] [Python] Relaxed list to Sequence in most parameter types (#188543)
Using `Sequence` frees users from the need to cast to `list` in cases
where the underlying API does not really care about the type of the
container.

Note that accepting an `nb::sequence` is marginally slower than
accepting `nb::list` directly, because `__getitem__`, `__len__` etc need
to go through an extra layer of indirection. However, I expect the
performance difference to be negligible.
2026-03-25 19:15:38 +00:00
Sergei Lebedev
8afb4620d6
[MLIR] [Python] Fixed a long standing bug in the PyRegionListIterator (#188475)
`PyRegionIterator` did not account for start index/step, so this commit
removes it in favor of the sequence iterator provided by CPython.

The previous attempt in #137232 bitrotted, so I decided to open a new
PR.
2026-03-25 16:01:35 +00:00
Sergei Lebedev
396d63813c
[MLIR] [Python] More improvements to type annotations (#188468)
* `mlir.ir` now exports `_OperationBase`. It is handy to use when both
`Operation` and `OpView` are accepted.
* Added type arguments where they were missing, e.g.
`list[ir.Attribute]` instead of just `list`.
* Changed `Opview.build_generic` and `OpView.parse` to return `Self`
instead of the supertype `Type`.
* Changed the bindings generator to emit a parameterized `OpResult` when
the exact type is available.
2026-03-25 14:18:29 +00:00
Sergei Lebedev
69594b76f2
[MLIR] [Python] A few minor fixes to type annotations (#187956)
* ir.IntegerAttr.value is now an int
* ir.Value.type correctly returns a value of type _T
* ir.OpView.build_generic returns ir.Operation, which matches the
implementation.
2026-03-23 07:54:50 +00:00
Maksim Levental
c3f381ccfe
[mlir-python] Fix duplicate EnumAttr builder registration across dialects. (#187191)
When multiple dialects share td `#includes` (e.g. `affine` includes
`arith`), each dialect's `*_enum_gen.py` file registers attribute
builders under the same keys, causing "already registered" errors on the
second import; the first commit checks in such a case which currently
fails on main:

```
# | RuntimeError: Attribute builder for 'Arith_CmpFPredicateAttr' is already registered with func: <function _arith_cmpfpredicateattr at 0x78d13cbe9a80>
```

This PR implements a two-pronged fix:

1. Add `allow_existing=True` to `register_attribute_builder` (and the
underlying C++ `registerAttributeBuilder`). When set, silently skips
registration if the key already exists (first-wins semantics). This
handles `EnumInfo`-based builders which have no dialect prefix (e.g.
`AtomicRMWKindAttr`, `Arith_CmpFPredicateAttr`), which may be emitted by
every dialect whose td file includes the defining file;
2. Filter `EnumAttr` builders by `-bind-dialect` in
`EnumPythonBindingGen.cpp` and register them under dialect qualified
keys (`"dialect.AttrName"`). Update `OpPythonBindingGen.cpp` to look up
the same qualified keys for EnumAttr typed op attributes (detected via
`isSubClassOf("EnumAttr")`). Pass `-bind-dialect` from
`AddMLIRPython.cmake`.

This approach incurs no changes to `ir.py` registrations (no "builtin."
prefix), and no manual builder additions to individual dialect Python
files (unlike the previous attempt
https://github.com/llvm/llvm-project/pull/117918).

Note, this PR was "clauded" not "coded".
2026-03-19 21:02:23 -07:00
RattataKing
5a5c3176ef
[MLIR][Python] Add optional emit reset to exportSMTLIB (#187366)
Previously, the MLIR's python binding `smt.export_smtlib(...)` always
emit `(reset)` to the end of smtlib string as a solver terminator.
This PR added an option to suppress this trailing, as downstream users
like python z3 module don't need it.
2026-03-18 16:10:07 -04:00
Maksim Levental
e3d7bf290d
[MLIR][LLVM] add metadata attrs and llvm.named_metadata op (#186703)
This PR adds some LLVM metadata attributes and an `llvm.named_metadata`
container op (similar to `llvm.module_flags`) for those attributes.

Summary:

- Add MLIR attributes modeling LLVM IR metadata: `#llvm.md_string`,
`#llvm.md_const`, `#llvm.md_func`, and `#llvm.md_node`;
- Add `llvm.named_metadata` container op for module-level named metadata
nodes;
  - Add MLIR-to-LLVM-IR translation for the new attributes and op;
- Add C API functions (`mlirLLVMMDStringAttrGet`,
`mlirLLVMMDNodeAttrGet`, etc.);
- Add Python bindings (`llvm.MDStringAttr`, `llvm.MDConstantAttr`,
`llvm.MDFuncAttr`, `llvm.MDNodeAttr`, `llvm.FunctionType`).
2026-03-16 16:33:53 -07:00
Twice
044776691a
[MLIR][Python] Refine the behavior of Python-defined dialect reloading (#186128)
This includes several changes:
- `Dialect.load(reload=False)` will fail if the dialect was already
loaded in a different context. To prevent the further program abortion.
- `Dialect.load(reload=True)` implies `replace=True` in
dialect/operation registering.
- `PyGlobals::registerDialectImpl` now has a parameter `replace`.
- `register_dialect` and `register_operation` is no longer exposed in
`mlir.dialects.ext`.

This should solve the registering problem found in writing transform
test cases by @rolfmorel.
2026-03-15 10:25:24 +08:00
RattataKing
39b3b2e0e8
[MLIR][Python] Add type filter to walk() binding and add get_ops_of_type() utility (#186131)
MLIR's C++ `Operation::walk` supports type-filtered traversal (e.g.
`op->walk([](arith::AddIOp op) { ... })`), but the Python binding
`op.walk()` requires users to manually implement type filtering inside
the callback function.

This PR adds type filtering into the python binding `op.walk()`, if
users pass `op_class`, walk() will only apply callback to matching ops.

This PR also adds a common use helper in mlir/ir that collects all ops
of a given type into a list. Users can just call: `ops =
ir.get_ops_of_type(root, op_class)`.
2026-03-13 13:36:30 -04:00
Asher Mancinelli
9cee895333
[mlir][llvm] Expose llvm array type to CAPI and Python bindings (#185475)
This PR mostly copies everything to do with llvm.struct in the CAPI and
search-and-replaces `struct` with `array`.

Assisted-by: claude opus 4.6
2026-03-13 09:43:37 -07:00
Matthias Springer
13c00cbc2a
[mlir][IR] Rename DenseIntOrFPElementsAttr to DenseTypedElementsAttr (#185687)
`DenseIntOrFPElementsAttr` was recently generalized to accept any type
that implement the `DenseElementType` interface. The name
`DenseIntOrFPElementsAttr` does not make sense anymore. This commit
renames the attribute to `DenseTypedElementsAttr`. An alias is kept for
migration purposes. The alias will be removed after some time.
2026-03-13 17:27:23 +01:00
Jakub Kuderski
b45ce46905
[mlir][python] Avoid needless std::string copies in properties. NFC. (#186190)
MlirStringRef is copied into a Python str by nanobind's type_caster
anyway, so the intermediate std::string was a redundant allocation.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 14:53:33 -04:00
Sergei Lebedev
840cc16a8d
[MLIR] [Python] a few more fixes to type annotaitons (#186106)
* `_OperationBase.walk` was missing a default.
* `MLIRError` is now fully defined in C++. The monkey-patching
previously done in `_site_initialize` was opaque to type checkers.
2026-03-12 17:39:11 +00:00
Sergei Lebedev
ecda6d1691
[MLIR] [Bazel] Removed the stubgen plumbing added in #179211 (#185292)
The hope was that we would be able to reuse parts of this for
Google-internal builds and for open-source jaxlib builds, but we ended
up with custom plumbing in both cases, so I am now removing this
effectively dead code.
2026-03-08 20:52:23 +00:00
Sergei Lebedev
421bc73cff
[MLIR] [Python] Fixed a few issues in the type annotations (#183021)
* Removed an explicit `nb::sig` for `static_typeid`. The inferred type
would
work just fine, and unqualified `TypeID`, which was there previously,
only
  really works for core types in the `ir` submodule.
* `DefaultingPyMlir*` helpers also produce qualified types, e.g.
  `_mlir.ir.Location` instead of bare `Location`.
* `ir.*.__enter__` now returns a concrete type instead of `object`, e.g.
  `ir.Context.__enter__` returns `Context`.
* `loc_tracebacks` uses `Generator` as the return type, since this is
what
  `contextmanager` expects in typeshed.
* Changed static methods on subclasses of `DenseElementsAttribute` to
return
  that concrete subclass, instead of `DenseElementsAttribute`.

---------

Co-authored-by: Maksim Levental <maksim.levental@gmail.com>
2026-03-08 13:22:04 +00:00
Twice
f0142833b6
[MLIR][Python] Move operation/dialect name retrieving as a util function (#184605)
We have a common pattern that retrieve an operation name or dialect name
from a `type` or `str` in the rewrite nanobind module, so better to make
it a common util function.

---------

Co-authored-by: Rolf Morel <rolfmorel@gmail.com>
2026-03-05 10:37:12 +08:00
Rolf Morel
756d068ead
[MLIR][Python][Transform] Expose PatternDescriptorOpInterface to Python (#184331)
Makes it possible to include Python-defined rewrite patterns in
transform-dialect schedules, inside of `transform.apply_patterns`, which
upon execution of the schedule runs the pattern in a greedy rewriter.

With assistance of Claude.
2026-03-04 10:19:59 +00:00
Jakub Kuderski
2c9720972e
[mlir][python] Add stable ABI (abi3) support (#183856)
Add `MLIR_ENABLE_PYTHON_STABLE_ABI` cmake flag to build bindings against
the Python limited/stable API (abi3 / PEP 384). This allow for
compatibility across different >=3.12 versions with a single .so /
wheel. We also require CMake >=3.26.

The stable ABI restricts usage to a subset of the CPython C API: frame
and code object structs are opaque, so introspection APIs like
`PyCode_Addr2Location`, `PyFrame_GetLasti`, and `PyFrame_GetCode` are
unavailable. The traceback-based auto-location logic is dropped because
we don’t have stable ABI to produce complete locations.

Assisted-by: claude
2026-03-01 13:45:52 +00:00
Twice
4673cecc89
[MLIR][Python] Add support of convert_region_types and the bf integration test (#183664)
This PR adds the `convert_region_types` API to
`ConversionPatternRewriter` and introduces a new integration test,
`bf.py`, which demonstrates how to combine a Python-defined dialect, the
dialect conversion API, the pass manager, and the execution engine to
build a pure-Python JIT compilation pipeline.
2026-03-01 09:55:33 +08:00
RattataKing
f55b86258c
[mlir][Python] Drop Python <=3.9 compatibility path (#183416)
According to PR #163499, minimum Python version for mlir-py is now 3.10,
we no longer need patches for py<=3.9.

This change aligns with the Python version bump policy discussed
[here](https://discourse.llvm.org/t/rfc-adopt-regularly-scheduled-python-minimum-version-bumps/88841).
2026-02-27 10:29:12 -05:00
Twice
e2d2b23a5a
[MLIR][Python] Add convert_type API for TypeConverter (#183561)
This PR adds the  `convert_type` API for `TypeConverter`.
2026-02-27 00:30:00 +08:00
Twice
d7bd36d7e9
[MLIR][Python] Handle errors in dialect conversion properly (#183320)
Before this, MLIR error capture in `apply_partial_conversion` and
`apply_full_conversion` wasn’t handled, which meant any `emitError`
would crash the entire program. This PR adds the handling.
2026-02-26 10:22:24 +08:00
Twice
3f6648422c
[MLIR][Python] Fix typeid support for DynamicType and DynamicAttr (#183076)
Previously, we were using the static `typeid` of `DynamicType` for
checks, which is incorrect. We should instead check against the `typeid`
of `DynamicTypeDefinition` (which is a subclass of `SelfOwningTypeID`),
and register it via `register_type_caster` so that Python-defined types
can use `maybe_downcast`. (The attribute part is same.)
2026-02-25 21:58:13 +08:00
Rahul Kayaith
7160a4409a
[mlir][python] Fix segfault in DenseResourceElementsAttr.get_from_buffer for 0-d tensors (#183070)
When `ndim == 0`, `view->strides[view->ndim - 1]` is an out-of-bounds
access (unsigned underflow to `SIZE_MAX`). Use `view->itemsize` for
alignment instead, since a scalar buffer is trivially aligned to its
element size.

Fixes iree-org/iree-turbine#1312.
2026-02-24 11:01:58 -05:00
Twice
de3cefe560
[MLIR][Python] Add C and Python API for mlir::DynamicAttr (#182820)
This PR adds C and Python API support for `mlir::DynamicAttr`. It
primarily enables attributes in dialects that are dynamically generated
via IRDL to be constructed in Python, and allows retrieving the
parameters contained in a dynamic attribute from Python.

This PR is quite similiar to #182751, so I use tab to autocomplete some
code via github copilot, but manually verified.
2026-02-23 17:26:08 +08:00
Twice
059accca53
[MLIR][Python] Add Python and C API of mlir::DynamicType (#182751)
This PR adds C and Python API support for `mlir::DynamicType`. It
primarily enables types in dialects that are dynamically generated via
IRDL to be constructed in Python, and allows retrieving the parameters
contained in a dynamic type from Python.

---------

Co-authored-by: Rolf Morel <rolfmorel@gmail.com>
2026-02-23 12:14:56 +08:00
Twice
754828a122
[MLIR][Python] Remove redundant methods (#182459)
At the moment, Pylance reports errors in `ir.pyi`, saying that some
overloaded methods are invalid. After looking into it, I found that some
of these methods have duplicate signatures and are defined more than
once. This PR is mainly to clean up those methods.
2026-02-20 18:22:58 +08:00
Twice
ef5a11a51d
[MLIR][Python] Fix generic class signature of ir.Value (#182447)
In the type stub, `Generic` isn’t explicitly imported. This causes
Pyright/Pylance to report an error and treat `Value` as not being a
generic type. Explicitly using `typing.Generic` fixes this.
2026-02-20 17:05:31 +08:00
RattataKing
8f6866c9e9
[MLIR][Python] Clean remaining LLVM dependencies in MLIR-PY bindings (#181779)
This PR fixed
[issues](https://github.com/iree-org/iree/actions/runs/21956878131/job/63423389868#step:7:211)
caused by dropping `LLVMSupport` in PR #180986, dropped the remaining
direct llvm dependencies from mlir-python binding files.

Previously `LLVMSupport` was dropped while some uncleaned `mlir/CAPI/*`
sources were still being pulled into mlir-py, and those files still
directly depended on LLVM headers. The issue was masked via a global
`include_directories(${LLVM_INCLUDE_DIRS})` in `mlir/CMakeLists.txt`,
out-of-tree builds (e.g., IREE) that define Python module targets
outside the mlir/ directory tree would fail with "no such llvm file"
errors.
2026-02-17 15:23:10 -05:00
Rolf Morel
3b2233acd4
[MLIR][Python][SMT] Expose TypeIds for SMT Types (#181719)
Enables, among other things, the registration of type casters.
2026-02-16 18:43:47 +00:00
Maksim Levental
45bee6efe9
[mlir][Python] fix IRInterfaces.h (#181522)
https://github.com/llvm/llvm-project/pull/176920 added `IRInterfaces.h`
but didn't include it in either the list of [installed
headers](a1d7cda1d7/mlir/python/CMakeLists.txt (L557))
or `mlir/Bindings/Python`. This breaks downstreams. So just move the
header to `mlir/Bindings/Python`
2026-02-15 04:01:39 +00:00
Rolf Morel
a1d7cda1d7
[MLIR][Python] Impl XOpInterface(s) from Python, with X=Transform and X=MemoryEffects (#176920)
Provides the infrastructure for implementing and late-binding
OpInterfaces from Python.

* On the mlir-c API declaration side, each `XOpInterface` has a callback
struct, with a callback for each method and a userdata member (provided
as an arg to each method), and a
`mlirXOpInterfaceAttachFallbackModel(ctx, op_name, callbacks)` func.
* This CAPI is implemented by defining a subclass of
`XOpInterface::FallbackModel` that holds the callback struct and has
each method call the corresponding callback (with userdata as an arg).
Given a callback struct, a new `FallbackModel` is created and attached,
i.e. late bound, to the named op. (MLIR's interface infrastructure is
such that the thus registered `FallbackModel` will be returned in case
the op gets cast to the `XOpInterface`.)
* On the Python side, we expose a stand-in `XOpInterface` base class
which has one (class)method: `XOpInterface.attach(cls, op_name, ctx)`.
Python users subclass this class (`class MyInterfaceImpl(XOpInterface):
...`) and implement the interface's methods (with the right names and
signatures). The user calls `attach` on the subclass
(`MyInterfaceImpl.attach("my_dialect.my_op", ctx)`) which prepares the
callbacks struct _with userdata set to the subclass_ (as we use it to
lookup methods). These callbacks (and userdata) are then registered as
an `XOpInterface::FallbackModel` by
`mlirXOpInterfaceAttachFallbackModel(...)`. From then on the Python
methods will be used to respond to calls to the interface methods
(originating in C++).

This PR enables implementing the TransformOpInterface and the
MemoryEffectsOpInterface, both of which are required for making an op
into a transform op.

Everything besides the above linked code is there to facilitate exposing
the interfaces: the right types for the arguments of the methods are
exposed as are functions/methods for manipulating these arguments (e.g.
specifying side effects on `OpOperand`s and `OpResult`s and being able
to access and set the transform handles associated with args and
results).
2026-02-12 14:07:10 +00:00
RattataKing
75eecd27eb
[MLIR][Python] Remove partial LLVM APIs in python bindings (6/6) (#180986)
This PR completed work from
https://github.com/llvm/llvm-project/pull/178290.
Switched the last few python bindings that still relied on LLVM over to
the C API, and dropped `LLVMsupport` dependency from MLIR cmake.
2026-02-12 08:28:18 -05:00
Sergei Lebedev
e22db5cf61
[MLIR] [Bazel] Moved stubgen_runner.py out of llvm-project-overlay (#181029)
It was checked into the overlay by accident.
2026-02-11 22:29:30 +00:00
Matthias Springer
c6964b1b4d
[mlir][IR] DenseElementsAttr: Remove i1 dense packing special case (#180397)
`DenseElementsAttr` stores elements in a `ArrayRef<char>` buffer, where
each element is padded to a full byte. Before this commit, there used to
be a special storage format for `i1` elements: they used to be densely
packed, i.e., 1 bit per element. This commit removes the dense packing
special case for `i1`.

This commit removes complexity from `DenseElementsAttr`. If dense
packing is needed in the future it could be implemented in a general way
that works for all element types (based on #179122).

Discussion:
https://discourse.llvm.org/t/denseelementsattr-i1-element-type/62525
2026-02-11 15:56:08 +00:00
Twice
972aa597de
[MLIR][Python] Make traits declarative in python-defined operations (#180748)
This will support two syntax in python-defined dialects.

First is that traits can now be declared in class parameters, e.g.
```python
class ParentIsIfTrait(DynamicOpTrait): #define a python-side trait
    @staticmethod
    def verify_invariants(op) -> bool:
        if not isinstance(op.parent.opview, IfOp):
            op.location.emit_error(
                f"{op.name} should be put inside {IfOp.OPERATION_NAME}"
            )
            return False
        return True

class YieldOp( # attach two traits: IsTerminatorTrait, ParentIsIfTrait
    TestRegion.Operation, name="yield", traits=[IsTerminatorTrait, ParentIsIfTrait]
):
    ...
```

Second is that users can directly define
`verify_invariants`/`verify_region_invariants` methods in the operation
to add additional custom verification logic. And this is implemented via
traits.
```python
class YieldOp(TestRegion.Operation, name="yield", ...):
    value: Operand[Any]

    def verify_invariants(self) -> bool: # define a method directly
        if self.parent.results[0].type != self.value.type:
            self.location.emit_error(
                "result type mismatch between YieldOp and its parent IfOp"
            )
            return False
        return True
```

Previously we use `verify`/`verify_region` as method names (in
yesterday's PR #179705), but in this PR they are renamed to
`verify_invariants`/`verify_region_invariants` because there are
conflicts between the newly-added `verify` method and `ir.OpView.verify`
method:
- `verify_invariants` is just to attach **additional** verification
logic. but `OpView.verify` is to construct an OperationVerifer and do
full verification for an operation, so the semantics is not same between
these two. We should not shadow the `OpView.verify` method by defining a
new semantically-different `verify` method.
- it will make users confuse between these two `verify` methods, since
they have different meaning.
- if users didn't define the `verify` method in their python-defined
operation, `DynamicOpTraits.attach(opname, MyOpCls)` still do the
attaching (because `hasattr("verify")` returns `True`) and seg fault
(because we cannot attach `OpView.verify`).

---------

Co-authored-by: Rolf Morel <rolfmorel@gmail.com>
2026-02-11 20:39:58 +08:00
RattataKing
d380b29a7c
[MLIR][Python] Remove partial LLVM APIs in python bindings (5/n) (#180644)
This PR continues work from
https://github.com/llvm/llvm-project/pull/178290
Added local helper functions to avoid dependency on LLVM APIs.

---------

Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
2026-02-10 15:24:56 -05:00
Twice
dfc8fa80c9
[MLIR][Python] Refine trait support in MLIR Python (#180550)
This PR is mainly to address review suggestions in #179705.
2026-02-10 10:14:23 +08:00
Twice
fccbdcb15a
[MLIR][Python] Support dynamic traits in python-defined dialects (#179705)
This is a follow-up PR of #169045 and the second part of #179086.

In #179086, we added support for defining regions in Python-defined ops,
but its usefulness was quite limited because we still couldn’t mark an
op as a `Terminator` or `NoTerminator`. In this PR, we port the
`DynamicOpTrait` (introduced on the C++ side for `DynamicDialect` in
#177735) to Python, so we can dynamically attach traits to
Python-defined ops.
2026-02-09 22:26:56 +08:00
RattataKing
71a8973a3e
[MLIR][Python] Remove partial LLVM APIs in python bindings (4/n) (#180256)
This PR continues work from #178290 
It replaces some LLVM utilities with straightforward `std::`
equivalents.
2026-02-06 17:04:49 -05:00
RattataKing
b20fca82ab
[MLIR][Python] Remove partial LLVM APIs in python bindings (3/n) (#178984)
This PR continues work from #178290 
It cleans up multiple LLVM utilities in *.h files under
`mlir/Bindings/python`, along with the corresponding *.cpp files.
2026-02-04 13:18:32 -05:00
Twice
426374ed12
[MLIR][Python] Ignore the returned status of loadDialectModule in lookup functions (#179609)
Since `loadDialectModule` doesn't work for Python-defined dialects
(`mlir.dialects.ext`), currently we should lookup for
dialect/operation/opadaptor class even if the `loadDialectModule`
function fails. It's also because users can import some modules
manually, and we do already ignore it in some cases:

e2061328a8/mlir/lib/Bindings/Python/Globals.cpp (L163-L166)


Related to
https://github.com/llvm/llvm-project/pull/176920#discussion_r2762029022.
2026-02-04 15:25:07 +08:00
Maksim Levental
496d871ff3
[mlir][Python] fix liveContextMap under free-threading after #178529 (#179163)
#178529 introduced a small bug under free-threading by bumping a
reference count (or something like that) when accessing the operand list
passed to `build_generic`. This PR fixes that.
2026-02-02 05:08:51 +00:00
Twice
f992f9719f
[MLIR][Python] Support dialect conversion in python bindings (#177782)
This PR adds dialect conversion support to the MLIR Python bindings.
Because it introduces a number of new APIs, it’s a fairly large PR. It
mainly includes the following parts:

* Add a set of types and APIs to the C API, including
`MlirConversionTarget`, `MlirConversionPattern`, `MlirTypeConverter`,
`MlirConversionPatternRewriter`, and others.
* Add the corresponding types and APIs to the Python bindings.
* Extend `mlir-tblgen` with codegen for Python adaptor classes, which
generates an adaptor class for each op.

Note that this PR only adds support for 1-to-1 conversions, 1-to-N
type/value conversions are not supported yet.

---------

Co-authored-by: Maksim Levental <maksim.levental@gmail.com>
2026-01-31 12:37:49 +08:00
RattataKing
0c99ca3494
[MLIR][Python] Remove partial LLVM APIs in python bindings (2/n) (#178529)
This PR continues work from #178290.
Cleaned up LLVM utilities in IRCore.cpp: `enumerate`, `zip`, `ArrayRef`,
`hash_value`.
2026-01-29 17:21:40 -05:00
Jakub Kuderski
9aaf0b89f5
[mlir] Apply clang-tidy check llvm-use-vector-utils. NFC. (#178526) 2026-01-29 02:19:00 +00:00
RattataKing
0c41758502
[MLIR][Python] Remove partial LLVM APIs in python bindings (#178290)
mlir-py bindings should only rely on C mlir APIs.
This PR replaced partial LLVM utilities (`Twine`, `ArrayRef`,
`SmallVector`, `StringRef`) with equivalent STL, and added a `join()`
helper function in `IRCore.cpp` to concat strings.

---------

Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
2026-01-28 13:27:25 -05:00
Rolf Morel
ecb1b0b90f
[MLIR][Python] Fix overly specific type annotation on PyValue.owner (#178003) 2026-01-26 18:32:08 +00:00
Ryan Kim
ac88f7bcd4
[mlir][python] Support Arbitrary Precision Integers in MLIR C API and Python Bindings (#177733)
This PR extends the MLIR C API and Python bindings to support
**arbitrary-precision integers (`APInt`)**, overcoming the previous
limitation where `IntegerAttr` values were restricted to 64 bits.

Cryptographic applications often require integer types much larger than
standard machine words (e.g., the 256-bit modulus for the BN254 curve).
Previously, attempting to bind these values resulted in truncation or
errors. This PR exposes the underlying word-based `APInt` structure via
the C API and updates the Python bindings to seamlessly handle Python's
arbitrary-precision integers.
2026-01-24 23:05:03 -08:00