[llvm] [DirectX] Refactor RootSignature Backend to remove `to_underlying` from Root Parameter Header (PR #154249)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 10:25:21 PDT 2025


================
@@ -84,23 +84,21 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
   support::endian::write(BOS, Flags, llvm::endianness::little);
 
   SmallVector<uint32_t> ParamsOffsets;
-  for (const RootParameterInfo &P : ParametersContainer) {
-    support::endian::write(BOS, P.Header.ParameterType,
-                           llvm::endianness::little);
-    support::endian::write(BOS, P.Header.ShaderVisibility,
-                           llvm::endianness::little);
+  for (const RootParameterInfo &I : ParametersContainer) {
+    support::endian::write(BOS, I.Type, llvm::endianness::little);
+    support::endian::write(BOS, I.Visibility, llvm::endianness::little);
 
     ParamsOffsets.push_back(writePlaceholder(BOS));
   }
 
   assert(NumParameters == ParamsOffsets.size());
   for (size_t I = 0; I < NumParameters; ++I) {
     rewriteOffsetToCurrentByte(BOS, ParamsOffsets[I]);
-    const auto &[Type, Loc] = ParametersContainer.getTypeAndLocForParameter(I);
-    switch (Type) {
-    case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): {
+    const auto Info = ParametersContainer.getInfo(I);
----------------
bogner wrote:

We want a reference and not a copy here, so this needs at least `const auto &`. Better to just spell out the type explicitly though.
```suggestion
    const RootParameterInfo &Info = ParametersContainer.getInfo(I);
```

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


More information about the llvm-commits mailing list