summaryrefslogtreecommitdiff
path: root/src/jit/valuenumtype.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/jit/valuenumtype.h')
-rw-r--r--src/jit/valuenumtype.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/jit/valuenumtype.h b/src/jit/valuenumtype.h
new file mode 100644
index 0000000000..384d8e6869
--- /dev/null
+++ b/src/jit/valuenumtype.h
@@ -0,0 +1,72 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+
+// Defines the type "ValueNum".
+
+// This file exists only to break an include file cycle -- had been in ValueNum.h. But that
+// file wanted to include gentree.h to get GT_COUNT, and gentree.h wanted ton include ValueNum.h to
+// the ValueNum type.
+
+/*****************************************************************************/
+#ifndef _VALUENUMTYPE_H_
+#define _VALUENUMTYPE_H_
+/*****************************************************************************/
+
+// We will represent ValueNum's as unsigned integers.
+typedef UINT32 ValueNum;
+
+// There are two "kinds" of value numbers, which differ in their modeling of the actions of other threads.
+// "Liberal" value numbers assume that the other threads change contents of heap locations only at
+// synchronization points. Liberal VNs are appropriate, for example, in identifying CSE opportunities.
+// "Conservative" value numbers assume that the contents of heap locations change arbitrarily between
+// every two accesses. Conservative VNs are appropriate, for example, in assertion prop, where an observation
+// of a property of the value in some storage location is used to perform an optimization downstream on
+// an operation involving the contents of that storage location. If other threads may modify the storage
+// location between the two accesses, the observed property may no longer hold -- and conservative VNs make
+// it clear that the values need not be the same.
+//
+enum ValueNumKind { VNK_Liberal, VNK_Conservative };
+
+struct ValueNumPair
+{
+private:
+ ValueNum m_liberal;
+ ValueNum m_conservative;
+public:
+ ValueNum GetLiberal() const { return m_liberal; }
+ void SetLiberal(ValueNum vn) { m_liberal = vn; }
+ ValueNum GetConservative() const { return m_conservative; }
+ void SetConservative(ValueNum vn) { m_conservative = vn; }
+
+ ValueNum* GetLiberalAddr() { return &m_liberal; }
+ ValueNum* GetConservativeAddr() { return &m_conservative; }
+
+ ValueNum Get(ValueNumKind vnk) { return vnk == VNK_Liberal ? m_liberal : m_conservative; }
+
+ void SetBoth(ValueNum vn)
+ {
+ m_liberal = vn;
+ m_conservative = vn;
+ }
+
+ void operator=(const ValueNumPair& vn2)
+ {
+ m_liberal = vn2.m_liberal;
+ m_conservative = vn2.m_conservative;
+ }
+
+ // Initializes both elements to "NoVN". Defined in ValueNum.cpp.
+ ValueNumPair();
+
+ ValueNumPair(ValueNum lib, ValueNum cons) : m_liberal(lib), m_conservative(cons) {}
+
+ // True iff neither element is "NoVN". Defined in ValueNum.cpp.
+ bool BothDefined() const;
+
+ bool BothEqual() const { return m_liberal == m_conservative; }
+};
+
+#endif // _VALUENUMTYPE_H_