MLIR 24.0.0git
InterfaceSupport.cpp
Go to the documentation of this file.
1//===- InterfaceSupport.cpp - MLIR Interface Support Classes --------------===//
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 defines several support classes for defining interfaces.
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/Support/Debug.h"
15#include "llvm/Support/raw_ostream.h"
16
17#define DEBUG_TYPE "interfaces"
18
19using namespace mlir;
20
21detail::InterfaceMap::InterfaceMap(InterfaceMap &&) = default;
22
24 for (auto &it : interfaces)
25 free(it.second);
26 interfaces = std::move(rhs.interfaces);
27 return *this;
28}
29
31 for (auto &it : interfaces)
32 free(it.second);
33}
34
35void detail::InterfaceMap::insert(TypeID interfaceId, void *conceptImpl) {
36 // Insert directly into the right position to keep the interfaces sorted.
37 auto *it =
38 llvm::lower_bound(interfaces, interfaceId, [](const auto &it, TypeID id) {
39 return compare(it.first, id);
40 });
41 if (it != interfaces.end() && it->first == interfaceId) {
42 LLVM_DEBUG(llvm::dbgs() << "Ignoring repeated interface registration\n");
43 free(conceptImpl);
44 return;
45 }
46 interfaces.insert(it, {interfaceId, conceptImpl});
47}
This class provides an efficient unique identifier for a specific C++ type.
Definition TypeID.h:107
This class provides an efficient mapping between a given Interface type, and a particular implementat...
InterfaceMap & operator=(InterfaceMap &&rhs)
Include the generated interface declarations.