Fix reading Time zone rules using Julian days (#17672)
[platform/upstream/coreclr.git] / src / jit / varset.h
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.
4
5 //
6 // This include file determines how VARSET_TP is implemented.
7 //
8 #ifndef _VARSET_INCLUDED_
9 #define _VARSET_INCLUDED_ 1
10
11 // A VARSET_TP is a set of (small) integers representing local variables.
12 // We implement varsets using the BitSet abstraction, which supports
13 // several different implementations.
14 //
15 // The set of tracked variables may change during a compilation, and variables may be
16 // re-sorted, so the tracked variable index of a variable is decidedly *not* stable.  The
17 // bitset abstraction supports labeling of bitsets with "epochs", and supports a
18 // debugging mode in which live bitsets must have the current epoch.  To use this feature,
19 // divide a compilation up into epochs, during which tracked variable indices are
20 // stable.
21
22 // Some implementations of BitSet may use a level of indirection.  Therefore, we
23 // must be careful about about assignment and initialization.  We often want to
24 // reason about VARSET_TP as immutable values, and just copying the contents would
25 // introduce sharing in the indirect case, which is usually not what's desired.  On
26 // the other hand, there are many cases in which the RHS value has just been
27 // created functionally, and the intialization/assignment is obviously its last
28 // use.  In these cases, allocating a new indirect representation for the lhs (if
29 // it does not already have one) would be unnecessary and wasteful.  Thus, for both
30 // initialization and assignment, we have normal versions, which do make copies to
31 // prevent sharing and definitely preserve value semantics, and "NOCOPY" versions,
32 // which do not.  Obviously, the latter should be used with care.
33
34 #include "bitset.h"
35 #include "compilerbitsettraits.h"
36
37 const unsigned UInt64Bits = sizeof(UINT64) * 8;
38
39 // This #define chooses the BitSet representation used for VARSET.
40 // The choices are defined in "bitset.h"; they currently include
41 // BSUInt64, BSShortLong, and BSUInt64Class.
42 #define VARSET_REP BSShortLong
43
44 #if VARSET_REP == BSUInt64
45
46 #include "bitsetasuint64.h"
47
48 typedef BitSetOps</*BitSetType*/ UINT64,
49                   /*Brand*/ VARSET_REP,
50                   /*Env*/ Compiler*,
51                   /*BitSetTraits*/ TrackedVarBitSetTraits>
52     VarSetOpsRaw;
53
54 typedef UINT64 VARSET_TP;
55
56 const unsigned lclMAX_TRACKED = UInt64Bits;
57
58 #define VARSET_REP_IS_CLASS 0
59
60 #elif VARSET_REP == BSShortLong
61
62 #include "bitsetasshortlong.h"
63
64 typedef BitSetOps</*BitSetType*/ BitSetShortLongRep,
65                   /*Brand*/ VARSET_REP,
66                   /*Env*/ Compiler*,
67                   /*BitSetTraits*/ TrackedVarBitSetTraits>
68     VarSetOpsRaw;
69
70 typedef BitSetShortLongRep VARSET_TP;
71
72 // Tested various sizes for max tracked locals. The largest value for which no throughput regression
73 // could be measured was 512. Going to 1024 showed the first throughput regressions.
74 // We anticipate the larger size will be needed to support better inlining.
75 // There were a number of failures when 512 was used for legacy, so we just retain the 128 value
76 // for legacy backend.
77
78 #if !defined(LEGACY_BACKEND)
79 const unsigned       lclMAX_TRACKED = 512;
80 #else
81 const unsigned lclMAX_TRACKED = 128;
82 #endif
83
84 #define VARSET_REP_IS_CLASS 0
85
86 #elif VARSET_REP == BSUInt64Class
87
88 #include "bitsetasuint64inclass.h"
89
90 typedef BitSetOps</*BitSetType*/ BitSetUint64<Compiler*, TrackedVarBitSetTraits>,
91                   /*Brand*/ VARSET_REP,
92                   /*Env*/ Compiler*,
93                   /*BitSetTraits*/ TrackedVarBitSetTraits>
94     VarSetOpsRaw;
95
96 typedef BitSetUint64<Compiler*, TrackedVarBitSetTraits> VARSET_TP;
97
98 const unsigned lclMAX_TRACKED = UInt64Bits;
99
100 #define VARSET_REP_IS_CLASS 1
101
102 #else
103
104 #error "Unrecognized BitSet implemention for VarSet."
105
106 #endif
107
108 // These types should be used as the types for VARSET_TP arguments and return values, respectively.
109 // Arg type represent the read only argument type, that can't be modified.
110 typedef VarSetOpsRaw::ValArgType VARSET_VALARG_TP;
111 typedef VarSetOpsRaw::RetValType VARSET_VALRET_TP;
112
113 #define VARSET_COUNTOPS 0
114 #if VARSET_COUNTOPS
115 typedef BitSetOpsWithCounter<VARSET_TP,
116                              VARSET_REP,
117                              Compiler*,
118                              TrackedVarBitSetTraits,
119                              VARSET_VALARG_TP,
120                              VARSET_VALRET_TP,
121                              VarSetOpsRaw::Iter>
122     VarSetOps;
123 #else
124 typedef VarSetOpsRaw VarSetOps;
125 #endif
126
127 #define ALLVARSET_REP BSUInt64
128
129 #if ALLVARSET_REP == BSUInt64
130
131 #include "bitsetasuint64.h"
132
133 typedef BitSetOps</*BitSetType*/ UINT64,
134                   /*Brand*/ ALLVARSET_REP,
135                   /*Env*/ Compiler*,
136                   /*BitSetTraits*/ AllVarBitSetTraits>
137     AllVarSetOps;
138
139 typedef UINT64 ALLVARSET_TP;
140
141 const unsigned lclMAX_ALLSET_TRACKED = UInt64Bits;
142
143 #define ALLVARSET_REP_IS_CLASS 0
144
145 #elif ALLVARSET_REP == BSShortLong
146
147 #include "bitsetasshortlong.h"
148
149 typedef BitSetOps</*BitSetType*/ BitSetShortLongRep,
150                   /*Brand*/ ALLVARSET_REP,
151                   /*Env*/ Compiler*,
152                   /*BitSetTraits*/ AllVarBitSetTraits>
153     AllVarSetOps;
154
155 typedef BitSetShortLongRep ALLVARSET_TP;
156
157 const unsigned lclMAX_ALLSET_TRACKED = lclMAX_TRACKED;
158
159 #define ALLVARSET_REP_IS_CLASS 0
160
161 #elif ALLVARSET_REP == BSUInt64Class
162
163 #include "bitsetasuint64inclass.h"
164
165 typedef BitSetOps</*BitSetType*/ BitSetUint64<Compiler*, AllVarBitSetTraits>,
166                   /*Brand*/ ALLVARSET_REP,
167                   /*Env*/ Compiler*,
168                   /*BitSetTraits*/ AllVarBitSetTraits>
169     AllVarSetOps;
170
171 typedef BitSetUint64<Compiler*, AllVarBitSetTraits> ALLVARSET_TP;
172
173 const unsigned lclMAX_ALLSET_TRACKED = UInt64Bits;
174
175 #define ALLVARSET_REP_IS_CLASS 1
176
177 #else
178 #error "Unrecognized BitSet implemention for AllVarSet."
179 #endif
180
181 // These types should be used as the types for ALLVARSET_TP arguments and return values, respectively.
182 typedef AllVarSetOps::ValArgType ALLVARSET_VALARG_TP;
183 typedef AllVarSetOps::RetValType ALLVARSET_VALRET_TP;
184
185 #endif // _VARSET_INCLUDED_