Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/lib/Parse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(LLVM_LINK_COMPONENTS
FrontendHLSL
FrontendOpenMP
MC
MCParser
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Parse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ add_clang_unittest(ParseTests
LLVMTestingSupport
clangTesting
LLVM_COMPONENTS
FrontendHLSL
Support
)
5 changes: 5 additions & 0 deletions llvm/include/llvm/Frontend/HLSL/HLSLRootSignatureUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Metadata;
namespace hlsl {
namespace rootsig {

LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const RootFlags &Flags);

LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
const RootConstants &Constants);

LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
const DescriptorTableClause &Clause);

Expand Down
33 changes: 33 additions & 0 deletions llvm/lib/Frontend/HLSL/HLSLRootSignatureUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,39 @@ static raw_ostream &operator<<(raw_ostream &OS,
return OS;
}

static const EnumEntry<RootFlags> RootFlagNames[] = {
{"AllowInputAssemblerInputLayout",
RootFlags::AllowInputAssemblerInputLayout},
{"DenyVertexShaderRootAccess", RootFlags::DenyVertexShaderRootAccess},
{"DenyHullShaderRootAccess", RootFlags::DenyHullShaderRootAccess},
{"DenyDomainShaderRootAccess", RootFlags::DenyDomainShaderRootAccess},
{"DenyGeometryShaderRootAccess", RootFlags::DenyGeometryShaderRootAccess},
{"DenyPixelShaderRootAccess", RootFlags::DenyPixelShaderRootAccess},
{"AllowStreamOutput", RootFlags::AllowStreamOutput},
{"LocalRootSignature", RootFlags::LocalRootSignature},
{"DenyAmplificationShaderRootAccess",
RootFlags::DenyAmplificationShaderRootAccess},
{"DenyMeshShaderRootAccess", RootFlags::DenyMeshShaderRootAccess},
{"CBVSRVUAVHeapDirectlyIndexed", RootFlags::CBVSRVUAVHeapDirectlyIndexed},
{"SamplerHeapDirectlyIndexed", RootFlags::SamplerHeapDirectlyIndexed},
};

raw_ostream &operator<<(raw_ostream &OS, const RootFlags &Flags) {
OS << "RootFlags(";
printFlags(OS, Flags, ArrayRef(RootFlagNames));
OS << ")";

return OS;
}

raw_ostream &operator<<(raw_ostream &OS, const RootConstants &Constants) {
OS << "RootConstants(num32BitConstants = " << Constants.Num32BitConstants
<< ", " << Constants.Reg << ", space = " << Constants.Space
<< ", visibility = " << Constants.Visibility << ")";

return OS;
}

raw_ostream &operator<<(raw_ostream &OS, const DescriptorTable &Table) {
OS << "DescriptorTable(numClauses = " << Table.NumClauses
<< ", visibility = " << Table.Visibility << ")";
Expand Down
69 changes: 69 additions & 0 deletions llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,73 @@ TEST(HLSLRootSignatureTest, DescriptorTableDump) {
EXPECT_EQ(Out, Expected);
}

TEST(HLSLRootSignatureTest, DefaultRootConstantsDump) {
RootConstants Constants;
Constants.Num32BitConstants = 1;
Constants.Reg = {RegisterType::BReg, 3};

std::string Out;
llvm::raw_string_ostream OS(Out);
OS << Constants;
OS.flush();

std::string Expected = "RootConstants(num32BitConstants = 1, b3, space = 0, "
"visibility = All)";
EXPECT_EQ(Out, Expected);
}

TEST(HLSLRootSignatureTest, SetRootConstantsDump) {
RootConstants Constants;
Constants.Num32BitConstants = 983;
Constants.Reg = {RegisterType::BReg, 34593};
Constants.Space = 7;
Constants.Visibility = ShaderVisibility::Pixel;

std::string Out;
llvm::raw_string_ostream OS(Out);
OS << Constants;
OS.flush();

std::string Expected = "RootConstants(num32BitConstants = 983, b34593, "
"space = 7, visibility = Pixel)";
EXPECT_EQ(Out, Expected);
}

TEST(HLSLRootSignatureTest, NoneRootFlagsDump) {
RootFlags Flags = RootFlags::None;

std::string Out;
llvm::raw_string_ostream OS(Out);
OS << Flags;
OS.flush();

std::string Expected = "RootFlags(None)";
EXPECT_EQ(Out, Expected);
}

TEST(HLSLRootSignatureTest, AllRootFlagsDump) {
RootFlags Flags = RootFlags::ValidFlags;

std::string Out;
llvm::raw_string_ostream OS(Out);
OS << Flags;
OS.flush();

std::string Expected = "RootFlags("
"AllowInputAssemblerInputLayout | "
"DenyVertexShaderRootAccess | "
"DenyHullShaderRootAccess | "
"DenyDomainShaderRootAccess | "
"DenyGeometryShaderRootAccess | "
"DenyPixelShaderRootAccess | "
"AllowStreamOutput | "
"LocalRootSignature | "
"DenyAmplificationShaderRootAccess | "
"DenyMeshShaderRootAccess | "
"CBVSRVUAVHeapDirectlyIndexed | "
"SamplerHeapDirectlyIndexed)";

EXPECT_EQ(Out, Expected);
}

} // namespace
Loading