Skip to content

Commit 6de3c49

Browse files
committed
address comments
1 parent 3366897 commit 6de3c49

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

llvm/include/llvm/Analysis/DXILResource.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -594,18 +594,9 @@ class DXILResourceCounterDirectionMap {
594594
void populate(Module &M, DXILBindingMap &DBM);
595595

596596
ResourceCounterDirection
597-
operator[](const dxil::ResourceBindingInfo &Info) const {
598-
auto Lower = llvm::lower_bound(
599-
CounterDirections, Info,
600-
[](const auto &LHS, const auto &RHS) { return *LHS.first < RHS; });
597+
operator[](const dxil::ResourceBindingInfo &Info) const;
601598

602-
if (Lower == CounterDirections.end())
603-
return ResourceCounterDirection::Unknown;
604-
if (*Lower->first != Info)
605-
return ResourceCounterDirection::Unknown;
606-
607-
return Lower->second;
608-
}
599+
void print(raw_ostream &OS) const;
609600
};
610601

611602
class DXILResourceCounterDirectionAnalysis
@@ -646,6 +637,7 @@ class DXILResourceCounterDirectionWrapperPass : public ModulePass {
646637
void releaseMemory() override;
647638

648639
void print(raw_ostream &OS, const Module *M) const override;
640+
void dump() const;
649641
};
650642

651643
ModulePass *createDXILResourceCounterDirectionWrapperPassPass();

llvm/lib/Analysis/DXILResource.cpp

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,46 @@ void DXILResourceCounterDirectionMap::populate(Module &M, DXILBindingMap &DBM) {
940940
});
941941
}
942942

943+
ResourceCounterDirection DXILResourceCounterDirectionMap::operator[](
944+
const dxil::ResourceBindingInfo &Info) const {
945+
auto Lower = llvm::lower_bound(
946+
CounterDirections, Info,
947+
[](const auto &LHS, const auto &RHS) { return *LHS.first < RHS; });
948+
949+
if (Lower == CounterDirections.end())
950+
return ResourceCounterDirection::Unknown;
951+
if (*Lower->first != Info)
952+
return ResourceCounterDirection::Unknown;
953+
954+
return Lower->second;
955+
}
956+
957+
void DXILResourceCounterDirectionMap::print(raw_ostream &OS) const {
958+
OS << "Counter Directions:\n";
959+
for (const auto &Dir : CounterDirections) {
960+
const dxil::ResourceBindingInfo::ResourceBinding &RB =
961+
Dir.first->getBinding();
962+
963+
OS << " Binding(" << RB.RecordID << ", " << RB.Size << ", "
964+
<< RB.LowerBound << ", " << RB.Size << ", " << ")'s counter is ";
965+
966+
switch (Dir.second) {
967+
case ResourceCounterDirection::Increment:
968+
OS << "incremented\n";
969+
break;
970+
case ResourceCounterDirection::Decrement:
971+
OS << "decremented\n";
972+
break;
973+
case ResourceCounterDirection::Unknown:
974+
OS << "unknown\n";
975+
break;
976+
case ResourceCounterDirection::Invalid:
977+
OS << "invalid\n";
978+
break;
979+
}
980+
}
981+
}
982+
943983
void DXILResourceCounterDirectionWrapperPass::getAnalysisUsage(
944984
AnalysisUsage &AU) const {
945985
AU.addRequiredTransitive<DXILResourceBindingWrapperPass>();
@@ -963,13 +1003,17 @@ void DXILResourceCounterDirectionWrapperPass::print(raw_ostream &OS,
9631003
OS << "No resource directions have been built!\n";
9641004
return;
9651005
}
966-
// Map->print(OS, *DRTM, M->getDataLayout());
1006+
1007+
Map->print(OS);
9671008
}
9681009

969-
// #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
970-
// LLVM_DUMP_METHOD
971-
// void DXILResourceCounterDirectionWrapperPass::dump() const { print(dbgs(),
972-
// nullptr); } #endif
1010+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1011+
LLVM_DUMP_METHOD
1012+
void DXILResourceCounterDirectionWrapperPass::dump() const {
1013+
print(dbgs(), nullptr);
1014+
}
1015+
#endif
1016+
9731017
//===----------------------------------------------------------------------===//
9741018

9751019
AnalysisKey DXILResourceTypeAnalysis::Key;

0 commit comments

Comments
 (0)