[Mlir-commits] [mlir] [mlir][spirv] Support function argument decorations for ptr in the PhysicalStorageBuffer (PR #76353)

Kohei Yamaguchi llvmlistbot at llvm.org
Thu Jan 4 21:53:40 PST 2024


================
@@ -972,8 +972,73 @@ void spirv::FuncOp::print(OpAsmPrinter &printer) {
 }
 
 LogicalResult spirv::FuncOp::verifyType() {
-  if (getFunctionType().getNumResults() > 1)
+  FunctionType fnType = getFunctionType();
+  if (fnType.getNumResults() > 1)
     return emitOpError("cannot have more than one result");
+
+  auto funcOp = dyn_cast<spirv::FuncOp>(getOperation());
+
+  auto hasDecorationAttr = [&](spirv::Decoration decoration,
+                               unsigned argIndex) {
+    for (auto argAttr :
+         cast<FunctionOpInterface>(*funcOp).getArgAttrs(argIndex)) {
+      if (auto decAttr = dyn_cast<spirv::DecorationAttr>(argAttr.getValue()))
----------------
sott0n wrote:

Ok, I add checking the attribute name.

> It would be nice to add an IR test for such case to ignore #spirv.decoration attributes without spirv.decoration name.

I think that an attribute of an argument requires the decoration name, so this IR test expects an error `error: expected attribute name` for this case ( sets `#spirv.decoration` attributes without `spirv.decoration` name).

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


More information about the Mlir-commits mailing list