LLVM  8.0.1
MetadataImpl.h
Go to the documentation of this file.
1 //===- MetadataImpl.h - Helpers for implementing metadata -----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file has private helpers for implementing metadata types.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_IR_METADATAIMPL_H
15 #define LLVM_IR_METADATAIMPL_H
16 
17 #include "llvm/ADT/DenseSet.h"
18 #include "llvm/IR/Metadata.h"
19 
20 namespace llvm {
21 
22 template <class T, class InfoT>
24  const typename InfoT::KeyTy &Key) {
25  auto I = Store.find_as(Key);
26  return I == Store.end() ? nullptr : *I;
27 }
28 
29 template <class T> T *MDNode::storeImpl(T *N, StorageType Storage) {
30  switch (Storage) {
31  case Uniqued:
32  llvm_unreachable("Cannot unique without a uniquing-store");
33  case Distinct:
34  N->storeDistinctInContext();
35  break;
36  case Temporary:
37  break;
38  }
39  return N;
40 }
41 
42 template <class T, class StoreT>
44  switch (Storage) {
45  case Uniqued:
46  Store.insert(N);
47  break;
48  case Distinct:
49  N->storeDistinctInContext();
50  break;
51  case Temporary:
52  break;
53  }
54  return N;
55 }
56 
57 } // end namespace llvm
58 
59 #endif
unsigned char Storage
Storage flag for non-uniqued, otherwise unowned, metadata.
Definition: Metadata.h:69
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Implements a dense probed hash-table based set.
Definition: DenseSet.h:250
This file contains the declarations for metadata subclasses.
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
Definition: MetadataImpl.h:43
Key
PAL metadata keys.
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
Definition: MetadataImpl.h:23
StorageType
Active type of storage.
Definition: Metadata.h:66
iterator find_as(const LookupKeyT &Val)
Alternative version of find() which allows a different, and possibly less expensive, key type.
Definition: DenseSet.h:177
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
#define I(x, y, z)
Definition: MD5.cpp:58
#define N