@@ -940,6 +940,46 @@ void DXILResourceCounterDirectionMap::populate(Module &M, DXILBindingMap &DBM) {
940
940
});
941
941
}
942
942
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
+
943
983
void DXILResourceCounterDirectionWrapperPass::getAnalysisUsage (
944
984
AnalysisUsage &AU) const {
945
985
AU.addRequiredTransitive <DXILResourceBindingWrapperPass>();
@@ -963,13 +1003,17 @@ void DXILResourceCounterDirectionWrapperPass::print(raw_ostream &OS,
963
1003
OS << " No resource directions have been built!\n " ;
964
1004
return ;
965
1005
}
966
- // Map->print(OS, *DRTM, M->getDataLayout());
1006
+
1007
+ Map->print (OS);
967
1008
}
968
1009
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
+
973
1017
// ===----------------------------------------------------------------------===//
974
1018
975
1019
AnalysisKey DXILResourceTypeAnalysis::Key;
0 commit comments