| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[mlir] [irdl] Add support for regions in irdl-to-cpp (#158540) Fixes https://github.com/llvm/llvm-project/issues/158034 For the input mlir irdl.dialect @conditional_dialect { // A conditional operation with regions irdl.operation @conditional { // Create region constraints %r0 = irdl.region // Unconstrained region %r1 = irdl.region() // Region with no entry block arguments %v0 = irdl.any %r2 = irdl.region(%v0) // Region with one i1 entry block argument irdl.regions(cond: %r2, then: %r0, else: %r1) } } This produces the following cpp: https://gist.github.com/j2kun/d2095f108efbd8d403576d5c460e0c00 Summary of changes: - The op class and adaptor get named accessors to the regions Region &get<RegionName>() and getRegions() - The op now gets OpTrait::NRegions<3> and OpInvariants to trigger the region verification - Support for region block argument constraints is added, but not working for all constraints until codegen for irdl.is is added (filed https://github.com/llvm/llvm-project/issues/161018 and left a TODO). - Helper functions for the individual verification steps are added, following mlir-tblgen's format (in the above gist, __mlir_irdl_local_region_constraint_ConditionalOp_cond and similar), and verifyInvariantsImpl that calls them. - Regions are added in the builder ## Questions for the reviewer ### What is the "correct" interface for verification? I used mlir-tblgen on an analogous version of the example ConditionalOp in this PR, and I see an ::mlir::OpTrait::OpInvariants trait as well as cpp ::llvm::LogicalResult ConditionalOp::verifyInvariantsImpl() { { unsigned index = 0; (void)index; for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) if (::mlir::failed(__mlir_ods_local_region_constraint_test1(*this, region, "cond", index++))) return ::mlir::failure(); for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) if (::mlir::failed(__mlir_ods_local_region_constraint_test1(*this, region, "then", index++))) return ::mlir::failure(); for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(2))) if (::mlir::failed(__mlir_ods_local_region_constraint_test1(*this, region, "else", index++))) return ::mlir::failure(); } return ::mlir::success(); } ::llvm::LogicalResult ConditionalOp::verifyInvariants() { if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) return ::mlir::success(); return ::mlir::failure(); } However, OpInvariants only seems to need verifyInvariantsImpl, so it's not clear to me what is the purpose of the verifyInvariants function, or, if I leave out verifyInvariants, whether I need to call verify() in my implementation of verifyInvariantsImpl. In this PR, I omitted verifyInvariants and generated verifyInvariantsImpl. ### Is testing sufficient? I am not certain I implemented the builders properly, and it's unclear to me to what extent the existing tests check this (which look like they compile the generated cpp, but don't actually use it). Did I omit some standard function or overload? --------- Co-authored-by: Jeremy Kun <j2kun@users.noreply.github.com> | 10 个月前 | |
[MLIR][IRDL] Added IRDL to C++ Translation (#141248) This PR introduces a new tool, mlir-irdl-to-cpp, that converts IRDL to C++ definitions. The C++ definitions allow use of the IRDL-defined dialect in MLIR C++ infrastructure, enabling the use of conversion patterns with IRDL dialects for example. This PR also adds CMake utilities to easily integrate the IRDL dialects into MLIR projects. Note that most IRDL features are not supported. In general, we are only able to define simple types and operations. - The only type constraint supported is irdl.any. - Variadic operands and results are not supported. - Verifiers for the IRDL constraints are not generated. - Attributes are not supported. --------- Co-authored-by: Théo Degioanni <theo.degioanni.llvm.deluge062@simplelogin.fr> Co-authored-by: Fehr Mathieu <mathieu.fehr@gmail.com> | 1 年前 | |
[mlir] Remove unused local variables (NFC) (#163105) Identified with bugprone-unused-local-non-trivial-variable. | 9 个月前 | |
Include <vector> in TemplatingUtils.h (#149671) This is needed after 3ee0f97b950a550ef14e3adbdf45f507273f2190 | 1 年前 | |
[MLIR][IRDL] Added IRDL to C++ Translation (#141248) This PR introduces a new tool, mlir-irdl-to-cpp, that converts IRDL to C++ definitions. The C++ definitions allow use of the IRDL-defined dialect in MLIR C++ infrastructure, enabling the use of conversion patterns with IRDL dialects for example. This PR also adds CMake utilities to easily integrate the IRDL dialects into MLIR projects. Note that most IRDL features are not supported. In general, we are only able to define simple types and operations. - The only type constraint supported is irdl.any. - Variadic operands and results are not supported. - Verifiers for the IRDL constraints are not generated. - Attributes are not supported. --------- Co-authored-by: Théo Degioanni <theo.degioanni.llvm.deluge062@simplelogin.fr> Co-authored-by: Fehr Mathieu <mathieu.fehr@gmail.com> | 1 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 10 个月前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 1 年前 | ||
| 1 年前 |