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.hpp
181 lines (152 loc) · 4.33 KB
/
compilerbitsettraits.hpp
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
#defineCompilerBitSetTraits_HPP_DEFINED1
#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
unsignedTrackedVarBitSetTraits::GetSize(Compiler* comp)
{
return comp->lvaTrackedCount;
}
// static
unsignedTrackedVarBitSetTraits::GetArrSize(Compiler* comp, unsigned elemSize)
{
assert(elemSize == sizeof(size_t));
return comp->lvaTrackedCountInSizeTUnits;
}
// static
unsignedTrackedVarBitSetTraits::GetEpoch(Compiler* comp)
{
return comp->GetCurLVEpoch();
}
// static
BitSetSupport::BitSetOpCounter* TrackedVarBitSetTraits::GetOpCounter(Compiler* comp)
{
#if VARSET_COUNTOPS
return &Compiler::m_varsetOpCounter;
#else
returnnullptr;
#endif
}
///////////////////////////////////////////////////////////////////////////////
//
// AllVarBitSetTraits
//
///////////////////////////////////////////////////////////////////////////////
// static
unsignedAllVarBitSetTraits::GetSize(Compiler* comp)
{
returnmin(comp->lvaCount, lclMAX_ALLSET_TRACKED);
}
// static
unsignedAllVarBitSetTraits::GetArrSize(Compiler* comp, unsigned elemSize)
{
returnroundUp(GetSize(comp), elemSize);
}
// static
unsignedAllVarBitSetTraits::GetEpoch(Compiler* comp)
{
returnGetSize(comp);
}
// static
BitSetSupport::BitSetOpCounter* AllVarBitSetTraits::GetOpCounter(Compiler* comp)
{
#if ALLVARSET_COUNTOPS
return &Compiler::m_allvarsetOpCounter;
#else
returnnullptr;
#endif
}
///////////////////////////////////////////////////////////////////////////////
//
// BasicBlockBitSetTraits
//
///////////////////////////////////////////////////////////////////////////////
// static
unsignedBasicBlockBitSetTraits::GetSize(Compiler* comp)
{
return comp->fgCurBBEpochSize;
}
// static
unsignedBasicBlockBitSetTraits::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
unsignedBasicBlockBitSetTraits::GetEpoch(Compiler* comp)
{
return comp->GetCurBasicBlockEpoch();
}
// static
BitSetSupport::BitSetOpCounter* BasicBlockBitSetTraits::GetOpCounter(Compiler* comp)
{
returnnullptr;
}
///////////////////////////////////////////////////////////////////////////////
//
// 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
unsignedBitVecTraits::GetSize(BitVecTraits* b)
{
return b->size;
}
// static
unsignedBitVecTraits::GetArrSize(BitVecTraits* b, unsigned elemSize)
{
assert(elemSize == sizeof(size_t));
unsigned elemBits = 8 * elemSize;
returnroundUp(b->size, elemBits) / elemBits;
}
// static
unsignedBitVecTraits::GetEpoch(BitVecTraits* b)
{
return b->size;
}
// static
BitSetSupport::BitSetOpCounter* BitVecTraits::GetOpCounter(BitVecTraits* b)
{
returnnullptr;
}
#endif// CompilerBitSetTraits_HPP_DEFINED