Path: blob/main/contrib/llvm-project/llvm/lib/IR/MetadataImpl.h
35233 views
//===- MetadataImpl.h - Helpers for implementing metadata -----------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file has private helpers for implementing metadata types.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_IR_METADATAIMPL_H13#define LLVM_IR_METADATAIMPL_H1415#include "llvm/ADT/DenseSet.h"16#include "llvm/IR/Metadata.h"1718namespace llvm {1920template <class T, class InfoT>21static T *getUniqued(DenseSet<T *, InfoT> &Store,22const typename InfoT::KeyTy &Key) {23auto I = Store.find_as(Key);24return I == Store.end() ? nullptr : *I;25}2627template <class T> T *MDNode::storeImpl(T *N, StorageType Storage) {28switch (Storage) {29case Uniqued:30llvm_unreachable("Cannot unique without a uniquing-store");31case Distinct:32N->storeDistinctInContext();33break;34case Temporary:35break;36}37return N;38}3940template <class T, class StoreT>41T *MDNode::storeImpl(T *N, StorageType Storage, StoreT &Store) {42switch (Storage) {43case Uniqued:44Store.insert(N);45break;46case Distinct:47N->storeDistinctInContext();48break;49case Temporary:50break;51}52return N;53}5455} // end namespace llvm5657#endif585960