VR_UNKNOWN
};
-// Abstract class for ranges of any of the supported types.
+// Abstract class for representing subsets of values for various
+// supported types, such as the possible values of a variable.
+//
+// There are subclasses for each of integer, floating point, and pointer
+// types, each with their own strategies for efficiently representing
+// subsets of values.
+//
+// For efficiency, we can't precisely represent any arbitrary subset
+// of values of a type (which could require 2^N bits for a type of size N)
+// Hence operations on the subclasses may introduce imprecision
+// due to over-approximating the possible subsets.
//
// To query what types ranger and the entire ecosystem can support,
// use value_range::supports_type_p(tree type). This is a static
extern void add_vrange (const vrange &, hash &, unsigned flags = 0);
}
-// A pair of values representing the known bits in a range. Zero bits
+// A pair of values representing the known bits of a value. Zero bits
// in MASK cover constant values. Set bits in MASK cover unknown
-// values. VALUE are the known bits.
-//
-// Set bits in MASK (no meaningful information) must have their
-// corresponding bits in VALUE cleared, as this speeds up union and
-// intersect.
+// values. VALUE are the known bits for the bits where MASK is zero,
+// and must be zero for the unknown bits where MASK is set (needed as an
+// optimization of union and intersect)
+// For example:
+// VALUE: [..., 0, 1, 0]
+// MASK: [..., 1, 0, 0]
+// ^ ^ ^
+// | | known bit: {0}
+// | known bit: {1}
+// unknown bit: {0, 1}
class irange_bitmask
{
return true;
}
-// An integer range without any storage.
+// A subset of possible values for an integer type, leaving
+// allocation of storage to subclasses.
class irange : public vrange
{
tree ubound () const final override;
};
-// The NAN state as an opaque object.
+// The possible NAN state of a floating point value as an opaque object.
+// This represents one of the four subsets of { -NaN, +NaN },
+// i.e. one of {}, { -NaN }, { +NaN}, or { -NaN, +NaN }.
class nan_state
{
return m_neg_nan;
}
-// A floating point range.
+// A subset of possible values for a floating point type.
//
// The representation is a type with a couple of endpoints, unioned
-// with the set of { -NAN, +Nan }.
+// with a subset of { -NaN, +NaN }.
class frange final : public vrange
{