[llvm] [ReachingDefAnalysis] Turn MBBReachingDefsInfo into a proper class (NFC) (PR #110432)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 29 14:02:46 PDT 2024
================
@@ -65,6 +65,50 @@ struct PointerLikeTypeTraits<ReachingDef> {
}
};
+// The storage for all reaching definitions.
+class MBBReachingDefsInfo {
+public:
+ void init(unsigned NumBlockIDs) { AllReachingDefs.resize(NumBlockIDs); }
+
+ unsigned numBlockIDs() const { return AllReachingDefs.size(); }
+
+ void startBasicBlock(unsigned MBBNumber, unsigned NumRegUnits) {
+ AllReachingDefs[MBBNumber].resize(NumRegUnits);
+ }
+
+ void append(unsigned MBBNumber, unsigned Unit, int Def) {
+ AllReachingDefs[MBBNumber][Unit].push_back(Def);
+ }
+
+ void prepend(unsigned MBBNumber, unsigned Unit, int Def) {
+ auto &Defs = AllReachingDefs[MBBNumber][Unit];
+ Defs.insert(Defs.begin(), Def);
+ }
+
+ void replaceFront(unsigned MBBNumber, unsigned Unit, int Def) {
+ assert(!AllReachingDefs[MBBNumber][Unit].empty());
+ *AllReachingDefs[MBBNumber][Unit].begin() = Def;
+ }
+
+ void clear() { AllReachingDefs.clear(); }
+
+ ArrayRef<ReachingDef> defs(unsigned MBBNumber, unsigned Unit) const {
+ if (AllReachingDefs[MBBNumber].empty())
+ // Block IDs are not necessarily dense.
+ return ArrayRef<ReachingDef>();
+ return AllReachingDefs[MBBNumber][Unit];
+ }
+
+private:
+ /// All reaching defs of a given RegUnit for a given MBB.
+ using MBBRegUnitDefs = TinyPtrVector<ReachingDef>;
+ /// All reaching defs of all reg units for a given MBB
+ using MBBDefsInfo = std::vector<MBBRegUnitDefs>;
+
+ /// All reaching defs of all reg units for a all MBBs
----------------
nikic wrote:
```suggestion
/// All reaching defs of all reg units for all MBBs
```
https://github.com/llvm/llvm-project/pull/110432
More information about the llvm-commits
mailing list