[clang] [llvm] [HLSL][RootSignature] Metadata generation of RootFlags, RootConstants, RootDescriptors (PR #142010)
Finn Plummer via cfe-commits
cfe-commits at lists.llvm.org
Fri May 30 14:26:05 PDT 2025
================
@@ -187,6 +193,46 @@ MDNode *MetadataBuilder::BuildRootSignature() {
return MDNode::get(Ctx, GeneratedMetadata);
}
+MDNode *MetadataBuilder::BuildRootFlags(const RootFlags &Flags) {
+ IRBuilder<> Builder(Ctx);
+ return MDNode::get(Ctx, {
+ MDString::get(Ctx, "RootFlags"),
+ ConstantAsMetadata::get(
+ Builder.getInt32(llvm::to_underlying(Flags))),
+ });
+}
+
+MDNode *MetadataBuilder::BuildRootConstants(const RootConstants &Constants) {
+ IRBuilder<> Builder(Ctx);
+ return MDNode::get(
+ Ctx, {
+ MDString::get(Ctx, "RootConstants"),
+ ConstantAsMetadata::get(
+ Builder.getInt32(llvm::to_underlying(Constants.Visibility))),
+ ConstantAsMetadata::get(Builder.getInt32(Constants.Reg.Number)),
+ ConstantAsMetadata::get(Builder.getInt32(Constants.Space)),
+ ConstantAsMetadata::get(
+ Builder.getInt32(Constants.Num32BitConstants)),
+ });
+}
+
+MDNode *MetadataBuilder::BuildRootDescriptor(const RootDescriptor &Descriptor) {
+ IRBuilder<> Builder(Ctx);
+ std::string Name;
+ llvm::raw_string_ostream OS(Name);
+ OS << "Root" << ClauseType(llvm::to_underlying(Descriptor.Type));
----------------
inbelic wrote:
Sounds good. I have a note for a clean-up to do define the stringifying functions for the enums. Further, the pattern used here was propagated from descriptor tables, so I will update the other uses accordingly.
https://github.com/llvm/llvm-project/pull/142010
More information about the cfe-commits
mailing list