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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
// 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_HPP_DEFINED
#define CompilerBitSetTraits_HPP_DEFINED 1
#include "compilerbitsettraits.h"
#include "compiler.h"
///////////////////////////////////////////////////////////////////////////////
//
// CompAllocBitSetTraits
//
///////////////////////////////////////////////////////////////////////////////
// static
void* CompAllocBitSetTraits::Alloc(Compiler* comp, size_t byteSize)
{
return comp->getAllocator(CMK_bitset).allocate<char>(byteSize);
}
#ifdef DEBUG
// static
void* CompAllocBitSetTraits::DebugAlloc(Compiler* comp, size_t byteSize)
{
return comp->getAllocator(CMK_DebugOnly).allocate<char>(byteSize);
}
#endif // DEBUG
///////////////////////////////////////////////////////////////////////////////
//
// TrackedVarBitSetTraits
//
///////////////////////////////////////////////////////////////////////////////
// static
unsigned TrackedVarBitSetTraits::GetSize(Compiler* comp)
{
return comp->lvaTrackedCount;
}
// static
unsigned TrackedVarBitSetTraits::GetArrSize(Compiler* comp, unsigned elemSize)
{
assert(elemSize == sizeof(size_t));
return comp->lvaTrackedCountInSizeTUnits;
}
// static
unsigned TrackedVarBitSetTraits::GetEpoch(Compiler* comp)
{
return comp->GetCurLVEpoch();
}
// static
BitSetSupport::BitSetOpCounter* TrackedVarBitSetTraits::GetOpCounter(Compiler* comp)
{
#if VARSET_COUNTOPS
return &Compiler::m_varsetOpCounter;
#else
return nullptr;
#endif
}
///////////////////////////////////////////////////////////////////////////////
//
// AllVarBitSetTraits
//
///////////////////////////////////////////////////////////////////////////////
// static
unsigned AllVarBitSetTraits::GetSize(Compiler* comp)
{
return min(comp->lvaCount, lclMAX_ALLSET_TRACKED);
}
// static
unsigned AllVarBitSetTraits::GetArrSize(Compiler* comp, unsigned elemSize)
{
return roundUp(GetSize(comp), elemSize);
}
// static
unsigned AllVarBitSetTraits::GetEpoch(Compiler* comp)
{
return GetSize(comp);
}
// static
BitSetSupport::BitSetOpCounter* AllVarBitSetTraits::GetOpCounter(Compiler* comp)
{
#if ALLVARSET_COUNTOPS
return &Compiler::m_allvarsetOpCounter;
#else
return nullptr;
#endif
}
///////////////////////////////////////////////////////////////////////////////
//
// BasicBlockBitSetTraits
//
///////////////////////////////////////////////////////////////////////////////
// static
unsigned BasicBlockBitSetTraits::GetSize(Compiler* comp)
{
return comp->fgCurBBEpochSize;
}
// static
unsigned BasicBlockBitSetTraits::GetArrSize(Compiler* comp, unsigned elemSize)
{
// Assert that the epoch has been initialized. This is a convenient place to assert this because
// GetArrSize() is called for every function, via IsShort().
assert(GetEpoch(comp) != 0);
assert(elemSize == sizeof(size_t));
return comp->fgBBSetCountInSizeTUnits; // This is precomputed to avoid doing math every time this function is called
}
// static
unsigned BasicBlockBitSetTraits::GetEpoch(Compiler* comp)
{
return comp->GetCurBasicBlockEpoch();
}
// static
BitSetSupport::BitSetOpCounter* BasicBlockBitSetTraits::GetOpCounter(Compiler* comp)
{
return nullptr;
}
///////////////////////////////////////////////////////////////////////////////
//
// BitVecTraits
//
///////////////////////////////////////////////////////////////////////////////
// static
void* BitVecTraits::Alloc(BitVecTraits* b, size_t byteSize)
{
return b->comp->getAllocator(CMK_bitset).allocate<char>(byteSize);
}
#ifdef DEBUG
// static
void* BitVecTraits::DebugAlloc(BitVecTraits* b, size_t byteSize)
{
return b->comp->getAllocator(CMK_DebugOnly).allocate<char>(byteSize);
}
#endif // DEBUG
// static
unsigned BitVecTraits::GetSize(BitVecTraits* b)
{
return b->size;
}
// static
unsigned BitVecTraits::GetArrSize(BitVecTraits* b, unsigned elemSize)
{
assert(elemSize == sizeof(size_t));
unsigned elemBits = 8 * elemSize;
return roundUp(b->size, elemBits) / elemBits;
}
// static
unsigned BitVecTraits::GetEpoch(BitVecTraits* b)
{
return b->size;
}
// static
BitSetSupport::BitSetOpCounter* BitVecTraits::GetOpCounter(BitVecTraits* b)
{
return nullptr;
}
#endif // CompilerBitSetTraits_HPP_DEFINED
|