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())); 做区分

相关推荐
遇印记3 小时前
传输层,网络层
运维·服务器·网络·windows·学习
clorinda4 小时前
PyQt5学习:从界面搭建到与机器学习实战
学习
欣欣之王来了6 小时前
Vue3项目脚手架:Vite vs Vue CLI怎么选?
前端·学习·架构·项目·vue3教程
kaixin_啊啊6 小时前
【零基础学AI】第 7 章——让 AI 辅助学习和办公
人工智能·学习
信奥卷王6 小时前
[GESP202506 六级] 学习小组(含视频)
学习
启观川6 小时前
数据结构与算法-第 3 章 常用算法-贪心算法
数据结构·笔记·python·算法·贪心算法
宛 禾7 小时前
Qt 控件入门:QLabel 从拖拽到对象树,一篇讲透
c++·qt·学习
ab1237688 小时前
Spring WebSocket(STOMP)
笔记·websocket·springboot·stomp
无敌贵点大王8 小时前
嵌入式软件面试经(自用)
c语言·stm32·单片机·学习·mongodb·面试·职场和发展
Xudde.8 小时前
PwnLab: init 靶机渗透测试(Vulnhub Writeup)
笔记·学习·安全·web安全