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

Jakub Kuderski llvmlistbot at llvm.org
Fri Dec 29 08:18:22 PST 2023


================
@@ -972,8 +972,74 @@ 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()))
+        return decAttr.getValue() == decoration;
+    }
+    return false;
+  };
+
+  for (unsigned i = 0, e = funcOp.getNumArguments(); i != e; ++i) {
+    auto param = fnType.getInputs()[i];
----------------
kuhar wrote:

nit: use the full type, since it's not obvious based on the RHS only

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


More information about the Mlir-commits mailing list