1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 #ifndef CompilerBitSetTraits_DEFINED
6 #define CompilerBitSetTraits_DEFINED 1
10 #include "bitsetasshortlong.h"
12 ///////////////////////////////////////////////////////////////////////////////
14 // CompAllocBitSetTraits: a base class for other BitSet traits classes.
16 // The classes in this file define "BitSetTraits" arguments to the "BitSetOps" type, ones that assume that
17 // Compiler* is the "Env" type.
19 // This class just wraps the compiler's allocator.
21 class CompAllocBitSetTraits
24 static inline void* Alloc(Compiler* comp, size_t byteSize);
27 static inline void* DebugAlloc(Compiler* comp, size_t byteSize);
31 ///////////////////////////////////////////////////////////////////////////////
33 // TrackedVarBitSetTraits
35 // This class is customizes the bit set to represent sets of tracked local vars.
36 // The size of the bitset is determined by the # of tracked locals (up to some internal
37 // maximum), and the Compiler* tracks the tracked local epochs.
39 class TrackedVarBitSetTraits : public CompAllocBitSetTraits
42 static inline unsigned GetSize(Compiler* comp);
44 static inline unsigned GetArrSize(Compiler* comp, unsigned elemSize);
46 static inline unsigned GetEpoch(class Compiler* comp);
48 static inline BitSetSupport::BitSetOpCounter* GetOpCounter(Compiler* comp);
51 ///////////////////////////////////////////////////////////////////////////////
55 // This class is customizes the bit set to represent sets of all local vars (tracked or not) --
56 // at least up to some maximum index. (This index is private to the Compiler, and it is
57 // the responsibility of the compiler not to use indices >= this maximum.)
58 // We rely on the fact that variables are never deleted, and therefore use the
59 // total # of locals as the epoch number (up to the maximum).
61 class AllVarBitSetTraits : public CompAllocBitSetTraits
64 static inline unsigned GetSize(Compiler* comp);
66 static inline unsigned GetArrSize(Compiler* comp, unsigned elemSize);
68 static inline unsigned GetEpoch(class Compiler* comp);
70 static inline BitSetSupport::BitSetOpCounter* GetOpCounter(Compiler* comp);
73 ///////////////////////////////////////////////////////////////////////////////
75 // BasicBlockBitSetTraits
77 // This class is customizes the bit set to represent sets of BasicBlocks.
78 // The size of the bitset is determined by maximum assigned BasicBlock number
79 // (Compiler::fgBBNumMax) (Note that fgBBcount is not equal to this during inlining,
80 // when fgBBcount is the number of blocks in the inlined function, but the assigned
81 // block numbers are higher than the inliner function. fgBBNumMax counts both.
82 // Thus, if you only care about the inlinee, during inlining, this bit set will waste
83 // the lower numbered block bits.) The Compiler* tracks the BasicBlock epochs.
85 class BasicBlockBitSetTraits : public CompAllocBitSetTraits
88 static inline unsigned GetSize(Compiler* comp);
90 static inline unsigned GetArrSize(Compiler* comp, unsigned elemSize);
92 static inline unsigned GetEpoch(class Compiler* comp);
94 static inline BitSetSupport::BitSetOpCounter* GetOpCounter(Compiler* comp);
97 ///////////////////////////////////////////////////////////////////////////////
101 // This class simplifies creation and usage of "ShortLong" bitsets.
110 BitVecTraits(unsigned size, Compiler* comp) : size(size), comp(comp)
114 static inline void* Alloc(BitVecTraits* b, size_t byteSize);
117 static inline void* DebugAlloc(BitVecTraits* b, size_t byteSize);
120 static inline unsigned GetSize(BitVecTraits* b);
122 static inline unsigned GetArrSize(BitVecTraits* b, unsigned elemSize);
124 static inline unsigned GetEpoch(BitVecTraits* b);
126 static inline BitSetSupport::BitSetOpCounter* GetOpCounter(BitVecTraits* b);
129 #endif // CompilerBitSetTraits_DEFINED