Add tmp support for tci/trowexpandadd and printFormat for tprint#724
Add tmp support for tci/trowexpandadd and printFormat for tprint#724FangRui0 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an optional scratch tile buffer (tmp) to the pto.trowexpandadd and pto.tci operations, and adds an optional printFormat attribute to pto.tprint to control formatting width and precision. It updates the corresponding assembly formats, verifiers, and EmitC/Memref conversion passes. The reviewer feedback focuses on code simplification and correctness: specifically, using the ODS-generated getPrintFormat() helper to avoid manual attribute null-checks, and conditionally returning a null ArrayAttr for pto.tprint when the default format is used to prevent EmitC from generating empty template brackets (TPRINT<>).
| templateArgVec.push_back( | ||
| emitc::OpaqueAttr::get(ctx, printFormatTok(printFormat))); | ||
| } | ||
| ArrayAttr templateArgs = rewriter.getArrayAttr(templateArgVec); |
There was a problem hiding this comment.
When printFormat is 0 (the default), templateArgVec is empty. Using rewriter.getArrayAttr(templateArgVec) creates an empty ArrayAttr (i.e., []), which causes EmitC to generate empty template brackets TPRINT<> in the output C++ code.
To avoid generating empty template brackets for the default case, we can conditionally return a null ArrayAttr when the vector is empty, matching the pattern used for MGather above. This also means we don't need to relax the LIT test assertions with {{(<.*>)?}}.
| ArrayAttr templateArgs = rewriter.getArrayAttr(templateArgVec); | |
| ArrayAttr templateArgs = | |
| templateArgVec.empty() ? ArrayAttr{} : rewriter.getArrayAttr(templateArgVec); |
| auto printFormatAttr = getPrintFormatAttr(); | ||
| int64_t printFormat = printFormatAttr ? printFormatAttr.getInt() : 0; |
There was a problem hiding this comment.
Since printFormat is defined as a DefaultValuedOptionalAttr, ODS automatically generates a getPrintFormat() helper method that handles the default value and returns the underlying integer type directly. We can use this helper to simplify the code and avoid manual null-checking of the attribute.
| auto printFormatAttr = getPrintFormatAttr(); | |
| int64_t printFormat = printFormatAttr ? printFormatAttr.getInt() : 0; | |
| int64_t printFormat = getPrintFormat(); |
| int64_t printFormat = 0; | ||
| if (auto formatAttr = op.getPrintFormatAttr()) | ||
| printFormat = formatAttr.getInt(); |
There was a problem hiding this comment.
Similarly, we can use the ODS-generated getPrintFormat() helper here to simplify the code and avoid manual null-checking of the attribute.
| int64_t printFormat = 0; | |
| if (auto formatAttr = op.getPrintFormatAttr()) | |
| printFormat = formatAttr.getInt(); | |
| int64_t printFormat = op.getPrintFormat(); |
Codex Review该评论由 review 机器人自动更新。
Summary检查到 3 个问题: Findings
这个 PR 新增了显式
在这次修改之前, |
No description provided.