[llvm] [HLSL] Add in-memory representation of Semantic Signatures (PR #209907)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 14:52:18 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm/Frontend/HLSL/SemanticSignatures.h llvm/lib/Frontend/HLSL/SemanticSignatures.cpp llvm/unittests/Frontend/HLSLSemanticSignatureMetadataTest.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Frontend/HLSL/SemanticSignatures.cpp b/llvm/lib/Frontend/HLSL/SemanticSignatures.cpp
index 8032f5975..860fa7905 100644
--- a/llvm/lib/Frontend/HLSL/SemanticSignatures.cpp
+++ b/llvm/lib/Frontend/HLSL/SemanticSignatures.cpp
@@ -144,7 +144,8 @@ SemanticSignatureElement::fromMetadata(const MDNode *Node) {
Elem.GSStream = *GSStream;
if (Elem.SemanticIndices.size() != Elem.Rows)
- return makeError("number of semantic indices must equal the number of rows");
+ return makeError(
+ "number of semantic indices must equal the number of rows");
return Elem;
}
@@ -163,12 +164,12 @@ MDNode *SemanticSignatureElement::toMetadata(LLVMContext &Ctx) const {
for (uint32_t Index : SemanticIndices)
IndexOps.push_back(GetI32(Index));
- return MDNode::get(
- Ctx, {GetI32(SigId), MDString::get(Ctx, SemanticName),
- GetI32(static_cast<uint32_t>(CompType)),
- GetI32(static_cast<uint32_t>(SemanticKind)),
- MDNode::get(Ctx, IndexOps),
- GetI32(static_cast<uint32_t>(InterpMode)), GetI32(Rows),
- GetI8(Cols), GetI32(StartRow), GetI8(StartCol), GetI8(UsageMask),
- GetI8(DynIndexMask), GetI32(GSStream)});
+ return MDNode::get(Ctx,
+ {GetI32(SigId), MDString::get(Ctx, SemanticName),
+ GetI32(static_cast<uint32_t>(CompType)),
+ GetI32(static_cast<uint32_t>(SemanticKind)),
+ MDNode::get(Ctx, IndexOps),
+ GetI32(static_cast<uint32_t>(InterpMode)), GetI32(Rows),
+ GetI8(Cols), GetI32(StartRow), GetI8(StartCol),
+ GetI8(UsageMask), GetI8(DynIndexMask), GetI32(GSStream)});
}
diff --git a/llvm/unittests/Frontend/HLSLSemanticSignatureMetadataTest.cpp b/llvm/unittests/Frontend/HLSLSemanticSignatureMetadataTest.cpp
index 895049888..6833ee7c6 100644
--- a/llvm/unittests/Frontend/HLSLSemanticSignatureMetadataTest.cpp
+++ b/llvm/unittests/Frontend/HLSLSemanticSignatureMetadataTest.cpp
@@ -30,8 +30,7 @@ protected:
}
Metadata *getI8(uint8_t Val) {
- return ConstantAsMetadata::get(
- ConstantInt::get(Type::getInt8Ty(Ctx), Val));
+ return ConstantAsMetadata::get(ConstantInt::get(Type::getInt8Ty(Ctx), Val));
}
Metadata *getStr(StringRef Val) { return MDString::get(Ctx, Val); }
@@ -129,11 +128,12 @@ TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementSystemValue) {
// An unallocated element uses the row/col sentinels
TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementUnallocated) {
- MDNode *Node = getElement(/*SigId=*/0, "POSITION", /*CompType=*/9,
- /*SemanticKind=*/0, /*Indices=*/{0},
- /*InterpMode=*/0, /*Rows=*/1, /*Cols=*/4,
- /*StartRow=*/UnallocatedRow, /*StartCol=*/UnallocatedCol,
- /*UsageMask=*/0, /*DynIndexMask=*/0, /*GSStream=*/0);
+ MDNode *Node =
+ getElement(/*SigId=*/0, "POSITION", /*CompType=*/9,
+ /*SemanticKind=*/0, /*Indices=*/{0},
+ /*InterpMode=*/0, /*Rows=*/1, /*Cols=*/4,
+ /*StartRow=*/UnallocatedRow, /*StartCol=*/UnallocatedCol,
+ /*UsageMask=*/0, /*DynIndexMask=*/0, /*GSStream=*/0);
Expected<SemanticSignatureElement> Elem =
SemanticSignatureElement::fromMetadata(Node);
@@ -147,9 +147,9 @@ TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementUnallocated) {
// Every component type value maps onto the matching dxil::ElementType
TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementComponentTypes) {
for (dxil::ElementType CompType :
- {dxil::ElementType::I32, dxil::ElementType::U32,
- dxil::ElementType::F16, dxil::ElementType::F32,
- dxil::ElementType::F64, dxil::ElementType::I16}) {
+ {dxil::ElementType::I32, dxil::ElementType::U32, dxil::ElementType::F16,
+ dxil::ElementType::F32, dxil::ElementType::F64,
+ dxil::ElementType::I16}) {
MDNode *Node = getElement(
/*SigId=*/0, "A", static_cast<uint32_t>(CompType), /*SemanticKind=*/0,
/*Indices=*/{0}, /*InterpMode=*/0, /*Rows=*/1, /*Cols=*/1,
@@ -224,9 +224,8 @@ TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementGSStream) {
// A null node is not a valid signature element
TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementNull) {
- EXPECT_THAT_EXPECTED(
- SemanticSignatureElement::fromMetadata(nullptr),
- FailedWithMessage("signature element node is null"));
+ EXPECT_THAT_EXPECTED(SemanticSignatureElement::fromMetadata(nullptr),
+ FailedWithMessage("signature element node is null"));
}
// A node with the wrong number of operands is rejected
@@ -268,7 +267,8 @@ TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementInvalidCompType) {
}
// A semantic kind outside dxbc::PSV::SemanticKind is rejected
-TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementInvalidSemanticKind) {
+TEST_F(HLSLSemanticSignatureMetadataTest,
+ MetadataToElementInvalidSemanticKind) {
MDNode *Node = getElement(/*SigId=*/0, "A", /*CompType=*/9,
/*SemanticKind=*/100, /*Indices=*/{0},
/*InterpMode=*/0, /*Rows=*/1, /*Cols=*/1,
@@ -316,7 +316,8 @@ TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementInvalidStartCol) {
}
// The row/col sentinels must be set together
-TEST_F(HLSLSemanticSignatureMetadataTest, MetadataToElementInvalidSentinelPair) {
+TEST_F(HLSLSemanticSignatureMetadataTest,
+ MetadataToElementInvalidSentinelPair) {
MDNode *RowOnly = getElement(
/*SigId=*/0, "A", /*CompType=*/9, /*SemanticKind=*/0, /*Indices=*/{0},
/*InterpMode=*/0, /*Rows=*/1, /*Cols=*/1, /*StartRow=*/UnallocatedRow,
``````````
</details>
https://github.com/llvm/llvm-project/pull/209907
More information about the llvm-commits
mailing list