[Mlir-commits] [mlir] [mlir][ODS] Verify type constraints in Types and Attributes (PR #102326)

Matthias Springer llvmlistbot at llvm.org
Thu Aug 8 02:52:07 PDT 2024


matthias-springer wrote:

I took a look at attribute constraints. My implementation already generates the verifier, but a different part of the TableGen generator does not support it.

Example:
```
def TestAttrVerification : Test_Attr<"TestAttrVerification"> {
  let parameters = (ins AnyAttrOf<[I16Attr, I32Attr]>:$param);
  let mnemonic = "attr_verification";
  let assemblyFormat = "`<` $param `>`";
}
```

```
llvm-project/mlir/include/mlir/IR/CommonAttrConstraints.td:171:7: error: Missing `cppType` field in Attribute/Type parameter: anonymous_718
class AnyAttrOf<list<Attr> allowedAttrs, string summary = "",
```

The reason is that `AttributeConstraint` is slightly different from `TypeConstraint`: it does not have a `cppType`/`cppClassName` field. Adding that could be a larger change, so I'd rather do that in a separate commit.

I added another test to `attr-or-type-format.td` that shows that a verifier is generated for parameters that are attributes (`AttrDef`).


https://github.com/llvm/llvm-project/pull/102326


More information about the Mlir-commits mailing list