Skip to content

Commit 29a8edb

Browse files
committed
nfc: abstract the single RootElement serialzie to own method
1 parent 61d2b61 commit 29a8edb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/include/llvm/Frontend/HLSL/HLSLRootSignatureUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
4444
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
4545
const StaticSampler &StaticSampler);
4646

47+
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const RootElement &Element);
48+
4749
LLVM_ABI void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements);
4850

4951
class MetadataBuilder {

llvm/lib/Frontend/HLSL/HLSLRootSignatureUtils.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ template <class... Ts> OverloadedVisit(Ts...) -> OverloadedVisit<Ts...>;
339339

340340
} // namespace
341341

342-
void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements) {
342+
raw_ostream &operator<<(raw_ostream &OS, const RootElement &Element) {
343343
const auto Visitor = OverloadedVisit{
344344
[&OS](const RootFlags &Flags) { OS << Flags; },
345345
[&OS](const RootConstants &Constants) { OS << Constants; },
@@ -348,14 +348,17 @@ void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements) {
348348
[&OS](const DescriptorTable &Table) { OS << Table; },
349349
[&OS](const StaticSampler &Sampler) { OS << Sampler; },
350350
};
351+
std::visit(Visitor, Element);
352+
return OS;
353+
}
351354

355+
void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements) {
352356
OS << " RootElements{";
353357
bool First = true;
354358
for (const RootElement &Element : Elements) {
355359
if (!First)
356360
OS << ",";
357-
OS << " ";
358-
std::visit(Visitor, Element);
361+
OS << " " << Element;
359362
First = false;
360363
}
361364
OS << "}";

0 commit comments

Comments
 (0)