diff options
Diffstat (limited to 'llvm/lib/CodeGen/InterferenceCache.h')
-rw-r--r-- | llvm/lib/CodeGen/InterferenceCache.h | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/llvm/lib/CodeGen/InterferenceCache.h b/llvm/lib/CodeGen/InterferenceCache.h index 18aa5c7c5ad..ca51ef24236 100644 --- a/llvm/lib/CodeGen/InterferenceCache.h +++ b/llvm/lib/CodeGen/InterferenceCache.h @@ -1,4 +1,4 @@ -//===-- InterferenceCache.h - Caching per-block interference ---*- C++ -*--===// +//===- InterferenceCache.h - Caching per-block interference ----*- C++ -*--===// // // The LLVM Compiler Infrastructure // @@ -15,47 +15,53 @@ #ifndef LLVM_LIB_CODEGEN_INTERFERENCECACHE_H #define LLVM_LIB_CODEGEN_INTERFERENCECACHE_H +#include "llvm/ADT/SmallVector.h" +#include "llvm/CodeGen/LiveInterval.h" #include "llvm/CodeGen/LiveIntervalUnion.h" +#include "llvm/CodeGen/SlotIndexes.h" +#include "llvm/Support/Compiler.h" +#include <cassert> +#include <cstddef> +#include <cstdlib> namespace llvm { class LiveIntervals; +class MachineFunction; +class TargetRegisterInfo; class LLVM_LIBRARY_VISIBILITY InterferenceCache { - const TargetRegisterInfo *TRI; - LiveIntervalUnion *LIUArray; - MachineFunction *MF; - /// BlockInterference - information about the interference in a single basic /// block. struct BlockInterference { - BlockInterference() : Tag(0) {} - unsigned Tag; + unsigned Tag = 0; SlotIndex First; SlotIndex Last; + + BlockInterference() = default; }; /// Entry - A cache entry containing interference information for all aliases /// of PhysReg in all basic blocks. class Entry { /// PhysReg - The register currently represented. - unsigned PhysReg; + unsigned PhysReg = 0; /// Tag - Cache tag is changed when any of the underlying LiveIntervalUnions /// change. - unsigned Tag; + unsigned Tag = 0; /// RefCount - The total number of Cursor instances referring to this Entry. - unsigned RefCount; + unsigned RefCount = 0; /// MF - The current function. MachineFunction *MF; /// Indexes - Mapping block numbers to SlotIndex ranges. - SlotIndexes *Indexes; + SlotIndexes *Indexes = nullptr; /// LIS - Used for accessing register mask interference maps. - LiveIntervals *LIS; + LiveIntervals *LIS = nullptr; /// PrevPos - The previous position the iterators were moved to. SlotIndex PrevPos; @@ -72,13 +78,12 @@ class LLVM_LIBRARY_VISIBILITY InterferenceCache { unsigned VirtTag; /// Fixed interference in RegUnit. - LiveRange *Fixed; + LiveRange *Fixed = nullptr; /// Iterator pointing into the fixed RegUnit interference. LiveInterval::iterator FixedI; - RegUnitInfo(LiveIntervalUnion &LIU) - : VirtTag(LIU.getTag()), Fixed(nullptr) { + RegUnitInfo(LiveIntervalUnion &LIU) : VirtTag(LIU.getTag()) { VirtI.setMap(LIU.getMap()); } }; @@ -94,7 +99,7 @@ class LLVM_LIBRARY_VISIBILITY InterferenceCache { void update(unsigned MBBNum); public: - Entry() : PhysReg(0), Tag(0), RefCount(0), Indexes(nullptr), LIS(nullptr) {} + Entry() = default; void clear(MachineFunction *mf, SlotIndexes *indexes, LiveIntervals *lis) { assert(!hasRefs() && "Cannot clear cache entry with references"); @@ -134,13 +139,17 @@ class LLVM_LIBRARY_VISIBILITY InterferenceCache { // robin manner. enum { CacheEntries = 32 }; + const TargetRegisterInfo *TRI = nullptr; + LiveIntervalUnion *LIUArray = nullptr; + MachineFunction *MF = nullptr; + // Point to an entry for each physreg. The entry pointed to may not be up to // date, and it may have been reused for a different physreg. - unsigned char* PhysRegEntries; - size_t PhysRegEntriesCount; + unsigned char* PhysRegEntries = nullptr; + size_t PhysRegEntriesCount = 0; // Next round-robin entry to be picked. - unsigned RoundRobin; + unsigned RoundRobin = 0; // The actual cache entries. Entry Entries[CacheEntries]; @@ -149,9 +158,9 @@ class LLVM_LIBRARY_VISIBILITY InterferenceCache { Entry *get(unsigned PhysReg); public: - InterferenceCache() - : TRI(nullptr), LIUArray(nullptr), MF(nullptr), PhysRegEntries(nullptr), - PhysRegEntriesCount(0), RoundRobin(0) {} + friend class Cursor; + + InterferenceCache() = default; ~InterferenceCache() { free(PhysRegEntries); @@ -160,8 +169,9 @@ public: void reinitPhysRegEntries(); /// init - Prepare cache for a new function. - void init(MachineFunction*, LiveIntervalUnion*, SlotIndexes*, LiveIntervals*, - const TargetRegisterInfo *); + void init(MachineFunction *mf, LiveIntervalUnion *liuarray, + SlotIndexes *indexes, LiveIntervals *lis, + const TargetRegisterInfo *tri); /// getMaxCursors - Return the maximum number of concurrent cursors that can /// be supported. @@ -169,8 +179,8 @@ public: /// Cursor - The primary query interface for the block interference cache. class Cursor { - Entry *CacheEntry; - const BlockInterference *Current; + Entry *CacheEntry = nullptr; + const BlockInterference *Current = nullptr; static const BlockInterference NoInterference; void setEntry(Entry *E) { @@ -186,10 +196,9 @@ public: public: /// Cursor - Create a dangling cursor. - Cursor() : CacheEntry(nullptr), Current(nullptr) {} - ~Cursor() { setEntry(nullptr); } + Cursor() = default; - Cursor(const Cursor &O) : CacheEntry(nullptr), Current(nullptr) { + Cursor(const Cursor &O) { setEntry(O.CacheEntry); } @@ -198,6 +207,8 @@ public: return *this; } + ~Cursor() { setEntry(nullptr); } + /// setPhysReg - Point this cursor to PhysReg's interference. void setPhysReg(InterferenceCache &Cache, unsigned PhysReg) { // Release reference before getting a new one. That guarantees we can @@ -229,10 +240,8 @@ public: return Current->Last; } }; - - friend class Cursor; }; -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_LIB_CODEGEN_INTERFERENCECACHE_H |