[ARM] Move MVE VPT block tests into the Thumb2 directory. NFC
[llvm-core.git] / lib / IR / MetadataImpl.h
blobb4188dd7d3ee46e2da4f43091d15277807214e04
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.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_IR_METADATAIMPL_H
14 #define LLVM_IR_METADATAIMPL_H
16 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/IR/Metadata.h"
19 namespace llvm {
21 template <class T, class InfoT>
22 static T *getUniqued(DenseSet<T *, InfoT> &Store,
23 const typename InfoT::KeyTy &Key) {
24 auto I = Store.find_as(Key);
25 return I == Store.end() ? nullptr : *I;
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;
38 return N;
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;
53 return N;
56 } // end namespace llvm
58 #endif