diff options
author | Twice <twice@apache.org> | 2025-09-19 10:10:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-19 10:10:39 +0800 |
commit | e5114a2016557fc0dd6014b838e91ca025e23b29 (patch) | |
tree | b4b648ce4ace040ae590a92c79bab34a8d41c502 /clang/lib/AST/ByteCode/Compiler.cpp | |
parent | b26b40b22320ab8b684bfe2575fdbda1c6f2e4ee (diff) | |
download | llvm-e5114a2016557fc0dd6014b838e91ca025e23b29.zip llvm-e5114a2016557fc0dd6014b838e91ca025e23b29.tar.gz llvm-e5114a2016557fc0dd6014b838e91ca025e23b29.tar.bz2 |
[MLIR][Python] Add python bindings for IRDL dialect (#158488)
In this PR we add basic python bindings for IRDL dialect, so that python
users can create and load IRDL dialects in python. This allows users, to
some extent, to define dialects in Python without having to modify
MLIR’s CMake/TableGen/C++ code and rebuild, making prototyping more
convenient.
A basic example is shown below (and also in the added test case):
```python
# create a module with IRDL dialects
module = Module.create()
with InsertionPoint(module.body):
dialect = irdl.DialectOp("irdl_test")
with InsertionPoint(dialect.body):
op = irdl.OperationOp("test_op")
with InsertionPoint(op.body):
f32 = irdl.is_(TypeAttr.get(F32Type.get()))
irdl.operands_([f32], ["input"], [irdl.Variadicity.single])
# load the module
irdl.load_dialects(module)
# use the op defined in IRDL
m = Module.parse("""
module {
%a = arith.constant 1.0 : f32
"irdl_test.test_op"(%a) : (f32) -> ()
}
""")
```
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
0 files changed, 0 insertions, 0 deletions