[llvm] [HLSLSemanticSignatures] Implement the stacked packing of elements (PR #218060)

Finn Plummer via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 11:54:03 PDT 2026


================
@@ -0,0 +1,63 @@
+//===- SemanticSignaturePacking.cpp - HLSL signature packing helpers -----===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file implements helpers for packing HLSL semantic signatures.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Frontend/HLSL/SemanticSignaturePacking.h"
+#include "llvm/ADT/STLExtras.h"
+#include <cassert>
+
+using namespace llvm;
+using namespace llvm::hlsl;
+
+char SignaturePackingError::ID;
+
+void SignaturePackingError::log(raw_ostream &OS) const {
+  switch (Kind) {
+  case SignatureOverflow:
+    OS << "signature elements do not fit in 32 rows";
+    break;
+  }
+  OS << " (element " << ElementIndex << ")";
+}
+
+Error llvm::hlsl::packSignatureStacked(
+    MutableArrayRef<SemanticSignatureElement> Elements,
+    Triple::EnvironmentType ShaderStage, IOType IOTy) {
+  unsigned NextRow = 0;
+  for (const auto &[Index, Element] : enumerate(Elements)) {
----------------
inbelic wrote:

Updated to `&&` to make it more clear, (just `auto &` is not valid)

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


More information about the llvm-commits mailing list