[llvm] [HLSL][SemanticSignatures] Implement prefix stable packing (PR #215430)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 11:47:01 PDT 2026
================
@@ -0,0 +1,107 @@
+//===- SemanticSignaturePacking.h - 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 declares helpers for packing HLSL semantic signatures.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
+#define LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Frontend/HLSL/SemanticSignatures.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Error.h"
+#include "llvm/TargetParser/Triple.h"
+
+namespace llvm::hlsl {
+
+/// Identifies which signature associated with an entry point is being packed.
+enum class SemanticSignatureKind {
+ Input,
+ Output,
+ PatchConstOrPrim,
+};
+
+static constexpr unsigned MaxSignatureRows = 32;
+static constexpr unsigned MaxSignatureCols = 4;
----------------
farzonl wrote:
NIT: not askign for a change just trying to understand.
What is the relation between `MaxSignatureRows` and `MaxSignatureCols`? `MaxSignatureRows` does not seem to be used in any bit casting but `MaxSignatureCols` is. All the uses of `MaxSignatureCols` are for uint8_t. Should we expect this number to remain less than 8? If it could grow we should have some kind of note so the uint8_t get upgraded to uint16_t or higher.
you have these asserts below making me think these should always be fixed in size:
assert(Element.Rows > 0 && Element.Rows <= MaxSignatureRows &&
"signature element must have between 1 and 32 rows");
assert(Element.Cols > 0 && Element.Cols <= MaxSignatureCols &&
"signature element must have between 1 and 4 columns");
https://github.com/llvm/llvm-project/pull/215430
More information about the llvm-commits
mailing list