CIRCT  19.0.0git
Design.cpp
Go to the documentation of this file.
1 //===- Design.cpp - ESI design hierarchy implementation -------------------===//
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 // DO NOT EDIT!
10 // This file is distributed as part of an ESI package. The source for this file
11 // should always be modified within CIRCT (lib/dialect/ESI/runtime/cpp/).
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "esi/Design.h"
16 
17 #include <map>
18 #include <stdexcept>
19 
20 using namespace std;
21 using namespace esi;
22 
23 namespace esi {
24 
25 /// Build an index of children by AppID.
26 static map<AppID, Instance *>
27 buildIndex(const vector<unique_ptr<Instance>> &insts) {
28  map<AppID, Instance *> index;
29  for (auto &item : insts)
30  index[item->getID()] = item.get();
31  return index;
32 }
33 
34 /// Build an index of ports by AppID.
35 static map<AppID, const BundlePort &>
36 buildIndex(const vector<unique_ptr<BundlePort>> &ports) {
37  map<AppID, const BundlePort &> index;
38  for (auto &item : ports)
39  index.emplace(item->getID(), *item);
40  return index;
41 }
42 
43 HWModule::HWModule(std::optional<ModuleInfo> info,
44  std::vector<std::unique_ptr<Instance>> children,
45  std::vector<services::Service *> services,
46  std::vector<std::unique_ptr<BundlePort>> &ports)
47  : info(info), children(std::move(children)),
48  childIndex(buildIndex(this->children)), services(services),
49  ports(std::move(ports)), portIndex(buildIndex(this->ports)) {}
50 
51 } // namespace esi
Definition: esi.py:1
static map< AppID, const BundlePort & > buildIndex(const vector< unique_ptr< BundlePort >> &ports)
Build an index of ports by AppID.
Definition: Design.cpp:36