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

相关推荐
闪闪发亮的小星星8 分钟前
STK_00 学习方案路线
学习
一楼的猫44 分钟前
茄子写作助手——品牌搜索突破9万后的技术型品牌认知与官网入口指南
人工智能·学习·机器学习·chatgpt·ai写作
AOwhisky1 小时前
学习自测与解析:MySQL第五、六、七期核心知识点详解
运维·数据库·笔记·学习·mysql·云计算
niuniuyi~1 小时前
QT学习笔记
笔记·qt·学习
咸甜适中1 小时前
rust语言学习笔记Trait(十六)Error(错误)
笔记·学习·rust
xuhaoyu_cpp_java2 小时前
项目学习(三)代码生成器
java·经验分享·笔记·学习
my_daling2 小时前
松下伺服驱动器参数保存流程(已在松下A5上验证)
笔记
worilb2 小时前
Spring Cloud 学习与实践(8):Spring Cloud Gateway 统一入口、路由转发与双重跨域故障演练
学习·spring·spring cloud
初圣魔门首席弟子2 小时前
学习工作方法论与任务执行计划
学习
智者知已应修善业3 小时前
【51单片机初始化D5-D8亮,每按键按下D1到D4全亮,再按下恢复,如此循环】2024-3-26
c++·经验分享·笔记·算法·51单片机