[llvm-branch-commits] [mlir] [mlir] Add predicates to tablegen-defined properties (PR #120176)
Markus Böck via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 17 04:08:34 PST 2024
================
@@ -1033,6 +1033,60 @@ while (true) {{
emitVerifier(namedAttr.attr, namedAttr.name, getVarName(namedAttr.name));
}
+static void genPropertyVerifier(const OpOrAdaptorHelper &emitHelper,
+ FmtContext &ctx, MethodBody &body) {
+
+ // Code to get a reference to a property into a variable to avoid multiple
+ // evaluations while verifying a property.
+ // {0}: Property variable name.
+ // {1}: Property name, with the first letter capitalized, to find the getter.
+ // {2}: Property interface type.
+ const char *const fetchProperty = R"(
+ {2} {0} = this->get{1}(); (void){0};
+)";
+
+ // Code to verify that the predicate of a property holds. Embeds the
+ // condition inline.
+ // {0}: Property condition code, pre-tgfmt()'d.
+ // {1}: Emit error prefix.
+ // {2}: Property name.
+ // {3}: Property description.
+ const char *const verifyProperty = R"(
+ if (!({0}))
+ return {1}"property '{2}' failed to satiisfy constraint: {3}");
----------------
zero9178 wrote:
```suggestion
return {1}"property '{2}' failed to satisfy constraint: {3}");
```
https://github.com/llvm/llvm-project/pull/120176
More information about the llvm-branch-commits
mailing list