1//===- llvm/CAS/CASReference.h ----------------------------------*- C++ -*-===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//===----------------------------------------------------------------------===//
9#ifndef LLVM_CAS_CASREFERENCE_H
10#define LLVM_CAS_CASREFERENCE_H
26/// Base class for references to things in \a ObjectStore.
35 /// Get an internal reference.
37#if LLVM_ENABLE_ABI_BREAKING_CHECKS
38 assert(CAS == &ExpectedCAS &&
"Extracting reference for the wrong CAS");
43 /// Helper functions for DenseMapInfo.
60#if LLVM_ENABLE_ABI_BREAKING_CHECKS
63 "Cannot compare across CAS instances");
65 return InternalRef ==
RHS.InternalRef;
71 : InternalRef(InternalRef) {
72#if LLVM_ENABLE_ABI_BREAKING_CHECKS
77 "Reserved for DenseMapInfo");
87#if LLVM_ENABLE_ABI_BREAKING_CHECKS
92/// Reference to an object in an \a ObjectStore instance.
94/// If you have an ObjectRef, you know the object exists, and you can point at
95/// it from new nodes with \a ObjectStore::store(), but you don't know anything
96/// about it. "Loading" the object is a separate step that may not have
97/// happened yet, and which can fail (due to filesystem corruption) or
98/// introduce latency (if downloading from a remote store).
100/// \a ObjectStore::store() takes a list of these, and these are returned by \a
101/// ObjectStore::forEachRef() and \a ObjectStore::readRef(), which are accessors
102/// for nodes, and \a ObjectStore::getReference().
104/// \a ObjectStore::load() will load the referenced object, and returns \a
105/// ObjectHandle, a variant that knows what kind of entity it is. \a
106/// ObjectStore::getReferenceKind() can expect the type of reference without
107/// asking for unloaded objects to be loaded.
109 struct DenseMapTag {};
113 return LHS.hasSameInternalRef(
RHS);
126 /// Print internal ref and/or CASID. Only suitable for debugging.
137 assert(InternalRef != -1ULL &&
"Reserved for DenseMapInfo");
138 assert(InternalRef != -2ULL &&
"Reserved for DenseMapInfo");
145/// Handle to a loaded object in a \a ObjectStore instance.
147/// ObjectHandle encapulates a *loaded* object in the CAS. You need one
148/// of these to inspect the content of an object: to look at its stored
149/// data and references.
153 return LHS.hasSameInternalRef(
RHS);
159 /// Print internal ref and/or CASID. Only suitable for debugging.
185 return Ref.getDenseMapHash();
195#endif // LLVM_CAS_CASREFERENCE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines DenseMapInfo traits for DenseMap.
Handle to a loaded object in a ObjectStore instance.
friend class ReferenceBase
void print(raw_ostream &OS) const
Print internal ref and/or CASID. Only suitable for debugging.
friend bool operator!=(const ObjectHandle &LHS, const ObjectHandle &RHS)
LLVM_DUMP_METHOD void dump() const
friend bool operator==(const ObjectHandle &LHS, const ObjectHandle &RHS)
Reference to an object in an ObjectStore instance.
void print(raw_ostream &OS) const
Print internal ref and/or CASID. Only suitable for debugging.
friend bool operator==(const ObjectRef &LHS, const ObjectRef &RHS)
friend class ReferenceBase
friend bool operator!=(const ObjectRef &LHS, const ObjectRef &RHS)
static ObjectRef getDenseMapEmptyKey()
static ObjectRef getDenseMapTombstoneKey()
LLVM_DUMP_METHOD void dump() const
Content-addressable storage for objects.
Base class for references to things in ObjectStore.
static constexpr uint64_t getDenseMapTombstoneRef()
uint64_t getInternalRef(const ObjectStore &ExpectedCAS) const
Get an internal reference.
ReferenceBase(DenseMapEmptyTag)
static constexpr uint64_t getDenseMapEmptyRef()
bool isDenseMapTombstone() const
bool isDenseMapEmpty() const
void print(raw_ostream &OS, const ObjectHandle &This) const
bool isDenseMapSentinel() const
ReferenceBase(const ObjectStore *CAS, uint64_t InternalRef, bool IsHandle)
ReferenceBase(DenseMapTombstoneTag)
bool hasSameInternalRef(const ReferenceBase &RHS) const
unsigned getDenseMapHash() const
Helper functions for DenseMapInfo.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
hash_code hash_value(const FixedPointSemantics &Val)
@ Ref
The access may reference the value stored in memory.
static bool isEqual(cas::ObjectRef LHS, cas::ObjectRef RHS)
static cas::ObjectRef getTombstoneKey()
static unsigned getHashValue(cas::ObjectRef Ref)
static cas::ObjectRef getEmptyKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...