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

Lei Zhang llvmlistbot at llvm.org
Thu Jan 4 10:16:14 PST 2024


================
@@ -177,6 +177,31 @@ LogicalResult Serializer::processUndefOp(spirv::UndefOp op) {
   return success();
 }
 
+LogicalResult Serializer::processFuncParameter(spirv::FuncOp op) {
+  for (auto [idx, arg] : llvm::enumerate(op.getArguments())) {
+    uint32_t argTypeID = 0;
+    if (failed(processType(op.getLoc(), arg.getType(), argTypeID))) {
+      return failure();
+    }
+    auto argValueID = getNextID();
+
+    // Process decoration attributes of arguments.
+    auto funcOp = cast<FunctionOpInterface>(*op);
+    for (auto argAttr : funcOp.getArgAttrs(idx)) {
+      if (auto decAttr = dyn_cast<DecorationAttr>(argAttr.getValue())) {
----------------
antiagainst wrote:

This serializes all attributes of `DecorationAttr` type. I think we should actually anchor on `spirv.decoration` for serialization--given that users can attatch random attributes to function arguments. 

Could you add a test for this case? Like `{spirv.decoration = ..., random_attr = #spirv.decoration<...>}`. To show that we drop random attributes during serialization and deserialization roundtirp?

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


More information about the Mlir-commits mailing list