CIRCT 20.0.0git
Loading...
Searching...
No Matches
ESIServices.h
Go to the documentation of this file.
1//===- ESIServices.h - Code related to ESI services -------------*- C++ -*-===//
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#ifndef CIRCT_DIALECT_ESI_ESISERVICES_H
10#define CIRCT_DIALECT_ESI_ESISERVICES_H
11
13#include "circt/Support/LLVM.h"
14
15#include "mlir/Pass/Pass.h"
16#include <memory>
17#include <utility>
18
19namespace circt {
20namespace esi {
21
22/// Class which "dispatches" a service implementation request to its specified
23/// generator. Also serves as a registery for generators.
25public:
26 // All generators must support this function pointer signature.
27 using ServiceGeneratorFunc = std::function<LogicalResult(
28 ServiceImplementReqOp, ServiceDeclOpInterface, ServiceImplRecordOp)>;
29
30 // Since passes don't have access to a context at creation time (and
31 // Attributes are tied to the context), we need to delay lookup table creation
32 // until running the dispatch the first time. This is the function pointer
33 // signature to create and return that lookup table.
35 DenseMap<StringRef, ServiceGeneratorFunc> genLookupTable,
36 bool failIfNotFound)
37 : genLookupTable(std::move(genLookupTable)),
40
41 /// Get the global dispatcher.
43
44 /// Generate a service implementation if a generator exists in this registry.
45 /// If one is not found, return failure if the `failIfNotFound` flag is set.
46 LogicalResult generate(ServiceImplementReqOp, ServiceDeclOpInterface);
47
48 /// Add a generator to this registry.
49 void registerGenerator(StringRef implType, ServiceGeneratorFunc gen);
50
51private:
52 DenseMap<StringRef, ServiceGeneratorFunc> genLookupTable;
54};
55
56std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
58
59} // namespace esi
60} // namespace circt
61
62#endif
Class which "dispatches" a service implementation request to its specified generator.
Definition ESIServices.h:24
ServiceGeneratorDispatcher(DenseMap< StringRef, ServiceGeneratorFunc > genLookupTable, bool failIfNotFound)
Definition ESIServices.h:34
void registerGenerator(StringRef implType, ServiceGeneratorFunc gen)
Add a generator to this registry.
LogicalResult generate(ServiceImplementReqOp, ServiceDeclOpInterface)
Generate a service implementation if a generator exists in this registry.
static ServiceGeneratorDispatcher & globalDispatcher()
Get the global dispatcher.
DenseMap< StringRef, ServiceGeneratorFunc > genLookupTable
Definition ESIServices.h:52
ServiceGeneratorDispatcher(const ServiceGeneratorDispatcher &that)=default
std::function< LogicalResult(ServiceImplementReqOp, ServiceDeclOpInterface, ServiceImplRecordOp)> ServiceGeneratorFunc
Definition ESIServices.h:28
std::unique_ptr< OperationPass< ModuleOp > > createESIConnectServicesPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition esi.py:1