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

Jakub Kuderski llvmlistbot at llvm.org
Thu Dec 28 14:11:43 PST 2023


================
@@ -972,8 +972,75 @@ 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 hasDecorationAttr = [op = getOperation()](spirv::Decoration decoration,
+                                                 unsigned argIndex) {
+    if (auto funcOp = dyn_cast<FunctionOpInterface>(op)) {
+      for (auto argAttr : funcOp.getArgAttrs(argIndex))
+        if (auto decAttr = dyn_cast<spirv::DecorationAttr>(argAttr.getValue()))
+          return decAttr.getValue() == decoration;
+    }
+    return false;
+  };
+
+  auto funcOp = dyn_cast<spirv::FuncOp>(getOperation());
----------------
kuhar wrote:

Since we need it in the lambda above, we can define this variable earlier and capture in the lambda directly

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


More information about the Mlir-commits mailing list