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.
5 // Defines the type "ValueNum".
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
11 /*****************************************************************************/
12 #ifndef _VALUENUMTYPE_H_
13 #define _VALUENUMTYPE_H_
14 /*****************************************************************************/
16 // We will represent ValueNum's as unsigned integers.
17 typedef UINT32 ValueNum;
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.
39 ValueNum m_conservative;
42 ValueNum GetLiberal() const
46 void SetLiberal(ValueNum vn)
50 ValueNum GetConservative() const
52 return m_conservative;
54 void SetConservative(ValueNum vn)
59 ValueNum* GetLiberalAddr()
63 ValueNum* GetConservativeAddr()
65 return &m_conservative;
68 ValueNum Get(ValueNumKind vnk)
70 return vnk == VNK_Liberal ? m_liberal : m_conservative;
73 void SetBoth(ValueNum vn)
79 void operator=(const ValueNumPair& vn2)
81 m_liberal = vn2.m_liberal;
82 m_conservative = vn2.m_conservative;
85 // Initializes both elements to "NoVN". Defined in ValueNum.cpp.
88 ValueNumPair(ValueNum lib, ValueNum cons) : m_liberal(lib), m_conservative(cons)
92 // True iff neither element is "NoVN". Defined in ValueNum.cpp.
93 bool BothDefined() const;
95 bool BothEqual() const
97 return m_liberal == m_conservative;
101 #endif // _VALUENUMTYPE_H_