[all-commits] [llvm/llvm-project] 0e0db0: [mlir] Introduce IRDL dialect
Fehr Mathieu via All-commits
all-commits at lists.llvm.org
Tue Apr 4 12:18:50 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0e0db0a4d7fd606ee58595f997142f7f2476cbe6
https://github.com/llvm/llvm-project/commit/0e0db0a4d7fd606ee58595f997142f7f2476cbe6
Author: Mathieu Fehr <mathieu.fehr at gmail.com>
Date: 2023-04-04 (Tue, 04 Apr 2023)
Changed paths:
M mlir/include/mlir/Dialect/CMakeLists.txt
A mlir/include/mlir/Dialect/IRDL/CMakeLists.txt
A mlir/include/mlir/Dialect/IRDL/IR/CMakeLists.txt
A mlir/include/mlir/Dialect/IRDL/IR/IRDL.h
A mlir/include/mlir/Dialect/IRDL/IR/IRDL.td
A mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
A mlir/include/mlir/Dialect/IRDL/IR/IRDLTraits.h
A mlir/include/mlir/Dialect/IRDL/IR/IRDLTypes.td
M mlir/include/mlir/InitAllDialects.h
M mlir/lib/Dialect/CMakeLists.txt
A mlir/lib/Dialect/IRDL/CMakeLists.txt
A mlir/lib/Dialect/IRDL/IR/IRDL.cpp
A mlir/test/Dialect/IRDL/cmath.irdl.mlir
A mlir/test/Dialect/IRDL/testd.irdl.mlir
M mlir/test/mlir-opt/commandline.mlir
Log Message:
-----------
[mlir] Introduce IRDL dialect
This patch introduces the IRDL dialect, which allow users to represent
dynamic dialect definitions as an MLIR program.
The IRDL dialect defines operations, attributes, and types, using
attribute constraints. For example:
```
module {
irdl.dialect @cmath {
irdl.type @complex {
%0 = irdl.is f32
%1 = irdl.is f64
%2 = irdl.any_of(%0, %1)
irdl.parameters(%2)
}
irdl.operation @norm {
%0 = irdl.any
%1 = irdl.parametric @complex<%0>
irdl.operands(%1)
irdl.results(%0)
}
}
```
This program will define a new `cmath.complex` type, which expects a single
parameter, which is either an `f32` or an `f64`. It also defines an
`cmath.norm` operation, which expects a single `cmath.complex` type as operand,
and returns a value of the underlying type. Note that like PDL (which IRDL is
heavily inspired from), both uses of `%0` are expected to be of the same attribute.
IRDL handles attributes and types with the same operations, and does this by always
wrapping types in a `TypeAttr`. This is to simplify the language.
Depends on D144690
Reviewed By: rriddle, mehdi_amini
Differential Revision: https://reviews.llvm.org/D144692
More information about the All-commits
mailing list