mlir 编译器学习笔记之十 -- 数据类型

1、MLIR区分三种整数类型

IntegerType::get(context, 32, IntegerType::Signless); // 简写IntegerType::get(context, 32)

IntegerType::get(context, 32, IntegerType::Signed);

IntegerType::get(context, 32, IntegerType::Unsigned);

在 mlir/include/mlir/IR/BuiltinTypes.td中定义,所以td中i32/si32/ui32 是三种不同的数据类型

在开源CppEmitter::shouldMapToUnsigned中定义映射,Signless保存和Signed一致

在 mlir/include/mlir/Dialect/Arith/IR/ArithOps.td中Arith_IndexCastOp仅支持不带符号信息的数据类型SignlessInteger

2、自定义结构图类型:

hlc.struct_def @DemoKernelL1dAddr {

"totalBytes" : i32,

"bdAddrBase" : i32,

"buffer0" : i64,

"buffer1" : i64

}

hlc.struct_def @DemoKernelPara {

"l1dAddr" : !hlc.struct<@DemoKernelL1dAddr>

}

在主函数中需要将分离的参数和结构体进行绑定:结构体存储的是地址,get_field 取出地址,pointer_cast 转换为内存视图

3、MLIR 的 arith 方言只允许 i64(signless)

可以通过增加属性 constOp->setAttr("xxx", UnitAttr::get(rewriter.getContext())); 做区分

相关推荐
red_redemption1 小时前
自由学习记录(190)
学习
Pizza_Lawson1 小时前
spinningup学习笔记(二)
笔记·学习
吃好睡好便好1 小时前
在Matlab中绘制饼状图
开发语言·学习·matlab·3d·信息可视化
nashane1 小时前
HarmonyOS 6学习:外接键盘CapsLock键“失灵”?一招解锁大写输入
学习·华为·计算机外设·harmonyos
清钟沁桐1 小时前
mlir 编译器学习笔记之九 -- 后端生成
笔记·学习·mlir
叶~小兮1 小时前
Zabbix 7.0 深度原理与生产进阶运维学习笔记
运维·学习·zabbix
我想我不够好。1 小时前
2026.5.21 消防监控学习 1.5hours
学习
燐妤1 小时前
前端HTML编程6:ES6与前后端交互
前端·javascript·学习·html5
什仙1 小时前
Ansys Maxwell 默认求解器选择
人工智能·笔记·算法·基础·ansys·maxwell