LLVM  13.0.0git
MetadataImpl.h
Go to the documentation of this file.
1 //===- MetadataImpl.h - Helpers for implementing metadata -----------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file has private helpers for implementing metadata types.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_IR_METADATAIMPL_H
14 #define LLVM_IR_METADATAIMPL_H
15 
16 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/IR/Metadata.h"
18 
19 namespace llvm {
20 
21 template <class T, class InfoT>
23  const typename InfoT::KeyTy &Key) {
24  auto I = Store.find_as(Key);
25  return I == Store.end() ? nullptr : *I;
26 }
27 
28 template <class T> T *MDNode::storeImpl(T *N, StorageType Storage) {
29  switch (Storage) {
30  case Uniqued:
31  llvm_unreachable("Cannot unique without a uniquing-store");
32  case Distinct:
33  N->storeDistinctInContext();
34  break;
35  case Temporary:
36  break;
37  }
38  return N;
39 }
40 
41 template <class T, class StoreT>
42 T *MDNode::storeImpl(T *N, StorageType Storage, StoreT &Store) {
43  switch (Storage) {
44  case Uniqued:
45  Store.insert(N);
46  break;
47  case Distinct:
48  N->storeDistinctInContext();
49  break;
50  case Temporary:
51  break;
52  }
53  return N;
54 }
55 
56 } // end namespace llvm
57 
58 #endif
llvm
Definition: AllocatorList.h:23
llvm::MDNode::storeImpl
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
Definition: MetadataImpl.h:42
llvm::Metadata::Distinct
@ Distinct
Definition: Metadata.h:70
Metadata.h
llvm::Metadata::Temporary
@ Temporary
Definition: Metadata.h:70
llvm::getUniqued
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
Definition: MetadataImpl.h:22
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:481
DenseSet.h
llvm::Metadata::StorageType
StorageType
Active type of storage.
Definition: Metadata.h:70
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Metadata::Storage
unsigned char Storage
Storage flag for non-uniqued, otherwise unowned, metadata.
Definition: Metadata.h:73
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
N
#define N
llvm::Metadata::Uniqued
@ Uniqued
Definition: Metadata.h:70