Mesa (main): clc: Use kernel_arg_type_qual string to add const type qualifier to arg metadata

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 15 16:18:25 UTC 2021


Module: Mesa
Branch: main
Commit: 53d4dc7febacd29ffd4caea5aaef509bfeaaefec
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=53d4dc7febacd29ffd4caea5aaef509bfeaaefec

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Thu Nov 11 07:55:24 2021 -0800

clc: Use kernel_arg_type_qual string to add const type qualifier to arg metadata

Reviewed-by: Karol Herbst <kherbst at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13759>

---

 src/compiler/clc/clc_helpers.cpp | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp
index c5b0f29eaab..fb9265e283b 100644
--- a/src/compiler/clc/clc_helpers.cpp
+++ b/src/compiler/clc/clc_helpers.cpp
@@ -232,8 +232,11 @@ public:
 
       for (auto &kernel : kernels) {
 	 for (auto &arg : kernel.args) {
-            if (arg.typeId == typeId)
+            if (arg.typeId == typeId) {
                arg.addrQualifier = addrQualifier;
+               if (addrQualifier == CLC_KERNEL_ARG_ADDRESS_CONSTANT)
+                  arg.typeQualifier |= CLC_KERNEL_ARG_TYPE_CONST;
+            }
          }
       }
    }
@@ -249,10 +252,21 @@ public:
       assert(op->type == SPV_OPERAND_TYPE_LITERAL_STRING);
       str = reinterpret_cast<const char *>(ins->words + op->offset);
 
-      if (str.find("kernel_arg_type.") != 0)
+      size_t start = 0;
+      enum class string_type {
+         arg_type,
+         arg_type_qual,
+      } str_type;
+
+      if (str.find("kernel_arg_type.") == 0) {
+         start = sizeof("kernel_arg_type.") - 1;
+         str_type = string_type::arg_type;
+      } else if (str.find("kernel_arg_type_qual.") == 0) {
+         start = sizeof("kernel_arg_type_qual.") - 1;
+         str_type = string_type::arg_type_qual;
+      } else {
          return;
-
-      size_t start = sizeof("kernel_arg_type.") - 1;
+      }
 
       for (auto &kernel : kernels) {
          size_t pos;
@@ -270,12 +284,19 @@ public:
             if (arg.name.empty())
                break;
 
-            size_t typeEnd = str.find(',', pos);
-	    if (typeEnd == std::string::npos)
+            size_t entryEnd = str.find(',', pos);
+	    if (entryEnd == std::string::npos)
                break;
 
-            arg.typeName = str.substr(pos, typeEnd - pos);
-            pos = typeEnd + 1;
+            std::string entryVal = str.substr(pos, entryEnd - pos);
+            pos = entryEnd + 1;
+
+            if (str_type == string_type::arg_type) {
+               arg.typeName = std::move(entryVal);
+            } else if (str_type == string_type::arg_type_qual) {
+               if (entryVal.find("const") != std::string::npos)
+                  arg.typeQualifier |= CLC_KERNEL_ARG_TYPE_CONST;
+            }
          }
       }
    }



More information about the mesa-commit mailing list