This repository was archived by the owner on Jan 23, 2023. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathcompilerbitsettraits.h
129 lines (104 loc) · 4.19 KB
/
compilerbitsettraits.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#ifndef CompilerBitSetTraits_DEFINED
#defineCompilerBitSetTraits_DEFINED1
#include"bitset.h"
#include"compiler.h"
#include"bitsetasshortlong.h"
///////////////////////////////////////////////////////////////////////////////
//
// CompAllocBitSetTraits: a base class for other BitSet traits classes.
//
// The classes in this file define "BitSetTraits" arguments to the "BitSetOps" type, ones that assume that
// Compiler* is the "Env" type.
//
// This class just wraps the compiler's allocator.
//
classCompAllocBitSetTraits
{
public:
staticinlinevoid* Alloc(Compiler* comp, size_t byteSize);
#ifdef DEBUG
staticinlinevoid* DebugAlloc(Compiler* comp, size_t byteSize);
#endif// DEBUG
};
///////////////////////////////////////////////////////////////////////////////
//
// TrackedVarBitSetTraits
//
// This class is customizes the bit set to represent sets of tracked local vars.
// The size of the bitset is determined by the # of tracked locals (up to some internal
// maximum), and the Compiler* tracks the tracked local epochs.
//
classTrackedVarBitSetTraits : publicCompAllocBitSetTraits
{
public:
staticinlineunsignedGetSize(Compiler* comp);
staticinlineunsignedGetArrSize(Compiler* comp, unsigned elemSize);
staticinlineunsignedGetEpoch(classCompiler* comp);
staticinline BitSetSupport::BitSetOpCounter* GetOpCounter(Compiler* comp);
};
///////////////////////////////////////////////////////////////////////////////
//
// AllVarBitSetTraits
//
// This class is customizes the bit set to represent sets of all local vars (tracked or not) --
// at least up to some maximum index. (This index is private to the Compiler, and it is
// the responsibility of the compiler not to use indices >= this maximum.)
// We rely on the fact that variables are never deleted, and therefore use the
// total # of locals as the epoch number (up to the maximum).
//
classAllVarBitSetTraits : publicCompAllocBitSetTraits
{
public:
staticinlineunsignedGetSize(Compiler* comp);
staticinlineunsignedGetArrSize(Compiler* comp, unsigned elemSize);
staticinlineunsignedGetEpoch(classCompiler* comp);
staticinline BitSetSupport::BitSetOpCounter* GetOpCounter(Compiler* comp);
};
///////////////////////////////////////////////////////////////////////////////
//
// BasicBlockBitSetTraits
//
// This class is customizes the bit set to represent sets of BasicBlocks.
// The size of the bitset is determined by maximum assigned BasicBlock number
// (Compiler::fgBBNumMax) (Note that fgBBcount is not equal to this during inlining,
// when fgBBcount is the number of blocks in the inlined function, but the assigned
// block numbers are higher than the inliner function. fgBBNumMax counts both.
// Thus, if you only care about the inlinee, during inlining, this bit set will waste
// the lower numbered block bits.) The Compiler* tracks the BasicBlock epochs.
//
classBasicBlockBitSetTraits : publicCompAllocBitSetTraits
{
public:
staticinlineunsignedGetSize(Compiler* comp);
staticinlineunsignedGetArrSize(Compiler* comp, unsigned elemSize);
staticinlineunsignedGetEpoch(classCompiler* comp);
staticinline BitSetSupport::BitSetOpCounter* GetOpCounter(Compiler* comp);
};
///////////////////////////////////////////////////////////////////////////////
//
// BitVecTraits
//
// This class simplifies creation and usage of "ShortLong" bitsets.
//
structBitVecTraits
{
private:
unsigned size;
Compiler* comp;
public:
BitVecTraits(unsigned size, Compiler* comp) : size(size), comp(comp)
{
}
staticinlinevoid* Alloc(BitVecTraits* b, size_t byteSize);
#ifdef DEBUG
staticinlinevoid* DebugAlloc(BitVecTraits* b, size_t byteSize);
#endif// DEBUG
staticinlineunsignedGetSize(BitVecTraits* b);
staticinlineunsignedGetArrSize(BitVecTraits* b, unsigned elemSize);
staticinlineunsignedGetEpoch(BitVecTraits* b);
staticinline BitSetSupport::BitSetOpCounter* GetOpCounter(BitVecTraits* b);
};
#endif// CompilerBitSetTraits_DEFINED