[Mlir-commits] [mlir] Add support for MLIR to llvm vscale attribute (PR #67012)

Tobias Gysi llvmlistbot at llvm.org
Fri Sep 22 11:03:13 PDT 2023


================
@@ -2342,6 +2342,19 @@ ParseResult LLVMFuncOp::parse(OpAsmParser &parser, OperationState &result) {
   result.addAttribute(getFunctionTypeAttrName(result.name),
                       TypeAttr::get(type));
 
+  if (succeeded(parser.parseOptionalKeyword("vscale_range"))) {
----------------
gysit wrote:

I believe you can delete your printer and parser code and then the attribute should print and parse as part of the attribute dictionary. It is important to keep the attribute as a part of the operation argument list though:
`  OptionalAttr<UnnamedAddr>:$unnamed_addr,
    OptionalAttr<I64Attr>:$alignment,
    OptionalAttr<LLVM_VScaleRangeAttr>:$vscale_range
  );
`
This ensures the attribute is an inherent attribute of the operation itself, which means there is a convenient getter to access the attribute. Otherwise you indeed need to access the attribute using a key and cast it to the desired type.

However, the current solution works as well.

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


More information about the Mlir-commits mailing list