[WIP]mlir
学习下mlir
1. 基本概念
- 树形结构。Op,Region,Block,Op
- 使用基本块参数代替phi
- Operand结构
- 操作
- 返回值:OpResult
- regions
- attrDict,属性字典
- 参数:OpOperand, 经典的Use结构
- Value是ValueImpl*的包装,type+kind
- Type, TypeStorage* 实际上是AbstractType* = {dialect, interface, typeid,name, subtypes}
- interface vs trait
- interface想要语义描述和具体Op/dialect解耦, 给pass提供api
使用主要是1
2
3
4
5Dialect *dialect = ...;
if (DialectInlinerInterface *interface = dyn_cast<DialectInlinerInterface>(dialect)) {
// The dialect has provided an implementation of this interface.
...
} - trait 更加静态,为attrs/ops/types 提供公共信息,比如说side effects
Operation *op = ..; if (op->hasTrait<MyTrait>()) ...
- interface想要语义描述和具体Op/dialect解耦, 给pass提供api