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
8 changes: 4 additions & 4 deletions llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ struct DescriptorTable {
// Denotes that the previous NumClauses in the RootElement array
// are the clauses in the table.
uint32_t NumClauses = 0;

void dump(raw_ostream &OS) const;
};

raw_ostream &operator<<(raw_ostream &OS, const DescriptorTable &Table);

static const uint32_t NumDescriptorsUnbounded = 0xffffffff;
static const uint32_t DescriptorTableOffsetAppend = 0xffffffff;
// Models DTClause : CBV | SRV | UAV | Sampler, by collecting like parameters
Expand All @@ -127,10 +127,10 @@ struct DescriptorTableClause {
break;
}
}

void dump(raw_ostream &OS) const;
};

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

/// Models RootElement : RootFlags | RootConstants | RootDescriptor
/// | DescriptorTable | DescriptorTableClause
///
Expand Down
33 changes: 19 additions & 14 deletions llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ static raw_ostream &operator<<(raw_ostream &OS,
return OS;
}

void DescriptorTable::dump(raw_ostream &OS) const {
OS << "DescriptorTable(numClauses = " << NumClauses
<< ", visibility = " << Visibility << ")";
}

static raw_ostream &operator<<(raw_ostream &OS, const ClauseType &Type) {
switch (Type) {
case ClauseType::CBuffer:
Expand Down Expand Up @@ -137,14 +132,24 @@ static raw_ostream &operator<<(raw_ostream &OS,
return OS;
}

void DescriptorTableClause::dump(raw_ostream &OS) const {
OS << Type << "(" << Reg << ", numDescriptors = " << NumDescriptors
<< ", space = " << Space << ", offset = ";
if (Offset == DescriptorTableOffsetAppend)
raw_ostream &operator<<(raw_ostream &OS, const DescriptorTable &Table) {
OS << "DescriptorTable(numClauses = " << Table.NumClauses
<< ", visibility = " << Table.Visibility << ")";

return OS;
}

raw_ostream &operator<<(raw_ostream &OS, const DescriptorTableClause &Clause) {
OS << Clause.Type << "(" << Clause.Reg
<< ", numDescriptors = " << Clause.NumDescriptors
<< ", space = " << Clause.Space << ", offset = ";
if (Clause.Offset == DescriptorTableOffsetAppend)
OS << "DescriptorTableOffsetAppend";
else
OS << Offset;
OS << ", flags = " << Flags << ")";
OS << Clause.Offset;
OS << ", flags = " << Clause.Flags << ")";

return OS;
}

void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements) {
Expand All @@ -154,11 +159,11 @@ void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements) {
if (!First)
OS << ",";
OS << " ";
First = false;
if (const auto &Clause = std::get_if<DescriptorTableClause>(&Element))
Clause->dump(OS);
OS << *Clause;
if (const auto &Table = std::get_if<DescriptorTable>(&Element))
Table->dump(OS);
OS << *Table;
First = false;
}
OS << "}";
}
Expand Down
10 changes: 5 additions & 5 deletions llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEST(HLSLRootSignatureTest, DescriptorCBVClauseDump) {

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

std::string Expected = "CBV(b0, numDescriptors = 1, space = 0, "
Expand All @@ -41,7 +41,7 @@ TEST(HLSLRootSignatureTest, DescriptorSRVClauseDump) {

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

std::string Expected =
Expand All @@ -60,7 +60,7 @@ TEST(HLSLRootSignatureTest, DescriptorUAVClauseDump) {

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

std::string Expected =
Expand All @@ -84,7 +84,7 @@ TEST(HLSLRootSignatureTest, DescriptorSamplerClauseDump) {

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

std::string Expected = "Sampler(s0, numDescriptors = 2, space = 42, offset = "
Expand All @@ -100,7 +100,7 @@ TEST(HLSLRootSignatureTest, DescriptorTableDump) {

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

std::string Expected =
Expand Down