Fix reading Time zone rules using Julian days (#17672)
[platform/upstream/coreclr.git] / src / jit / valuenumtype.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 // Defines the type "ValueNum".
6
7 // This file exists only to break an include file cycle -- had been in ValueNum.h.  But that
8 // file wanted to include gentree.h to get GT_COUNT, and gentree.h wanted ton include ValueNum.h to
9 // the ValueNum type.
10
11 /*****************************************************************************/
12 #ifndef _VALUENUMTYPE_H_
13 #define _VALUENUMTYPE_H_
14 /*****************************************************************************/
15
16 // We will represent ValueNum's as unsigned integers.
17 typedef UINT32 ValueNum;
18
19 // There are two "kinds" of value numbers, which differ in their modeling of the actions of other threads.
20 // "Liberal" value numbers assume that the other threads change contents of memory locations only at
21 // synchronization points.  Liberal VNs are appropriate, for example, in identifying CSE opportunities.
22 // "Conservative" value numbers assume that the contents of memory locations change arbitrarily between
23 // every two accesses.  Conservative VNs are appropriate, for example, in assertion prop, where an observation
24 // of a property of the value in some storage location is used to perform an optimization downstream on
25 // an operation involving the contents of that storage location.  If other threads may modify the storage
26 // location between the two accesses, the observed property may no longer hold -- and conservative VNs make
27 // it clear that the values need not be the same.
28 //
29 enum ValueNumKind
30 {
31     VNK_Liberal,
32     VNK_Conservative
33 };
34
35 struct ValueNumPair
36 {
37 private:
38     ValueNum m_liberal;
39     ValueNum m_conservative;
40
41 public:
42     ValueNum GetLiberal() const
43     {
44         return m_liberal;
45     }
46     void SetLiberal(ValueNum vn)
47     {
48         m_liberal = vn;
49     }
50     ValueNum GetConservative() const
51     {
52         return m_conservative;
53     }
54     void SetConservative(ValueNum vn)
55     {
56         m_conservative = vn;
57     }
58
59     ValueNum* GetLiberalAddr()
60     {
61         return &m_liberal;
62     }
63     ValueNum* GetConservativeAddr()
64     {
65         return &m_conservative;
66     }
67
68     ValueNum Get(ValueNumKind vnk)
69     {
70         return vnk == VNK_Liberal ? m_liberal : m_conservative;
71     }
72
73     void SetBoth(ValueNum vn)
74     {
75         m_liberal      = vn;
76         m_conservative = vn;
77     }
78
79     void operator=(const ValueNumPair& vn2)
80     {
81         m_liberal      = vn2.m_liberal;
82         m_conservative = vn2.m_conservative;
83     }
84
85     // Initializes both elements to "NoVN".  Defined in ValueNum.cpp.
86     ValueNumPair();
87
88     ValueNumPair(ValueNum lib, ValueNum cons) : m_liberal(lib), m_conservative(cons)
89     {
90     }
91
92     // True iff neither element is "NoVN".  Defined in ValueNum.cpp.
93     bool BothDefined() const;
94
95     bool BothEqual() const
96     {
97         return m_liberal == m_conservative;
98     }
99 };
100
101 #endif // _VALUENUMTYPE_H_