CIRCT 20.0.0git
Loading...
Searching...
No Matches
MSFTOpInterfaces.cpp
Go to the documentation of this file.
1//===- MSFTOpInterfaces.cpp - Implement MSFT OpInterfaces -----------------===//
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
11
12using namespace circt;
13using namespace msft;
14
15LogicalResult circt::msft::verifyUnaryDynInstDataOp(Operation *op) {
16 auto inst = dyn_cast<DynamicInstanceOp>(op->getParentOp());
17 FlatSymbolRefAttr pathRef =
18 cast<UnaryDynInstDataOpInterface>(op).getPathSym();
19
20 if (inst && pathRef)
21 return op->emitOpError("cannot both have a global ref symbol and be a "
22 "child of a dynamic instance op");
23 if (!inst && !pathRef)
24 return op->emitOpError("must have either a global ref symbol of belong to "
25 "a dynamic instance op");
26 return success();
27}
28
29Operation *circt::msft::getHierPathTopModule(Location loc,
31 FlatSymbolRefAttr pathSym) {
32 assert(pathSym && "pathSym must be non-null");
33 auto ref = dyn_cast_or_null<hw::HierPathOp>(symCache.getDefinition(pathSym));
34 if (!ref) {
35 emitError(loc) << "could not find hw.hierpath " << pathSym;
36 return nullptr;
37 }
38 if (ref.getNamepath().empty())
39 return nullptr;
40 auto modSym = FlatSymbolRefAttr::get(
41 cast<hw::InnerRefAttr>(ref.getNamepath()[0]).getModule());
42 return symCache.getDefinition(modSym);
43}
44
45namespace circt {
46namespace msft {
47#include "circt/Dialect/MSFT/MSFTOpInterfaces.cpp.inc"
48} // namespace msft
49} // namespace circt
assert(baseType &&"element must be base type")
This stores lookup tables to make manipulating and working with the IR more efficient.
Definition HWSymCache.h:27
mlir::Operation * getDefinition(mlir::Attribute attr) const override
Lookup a definition for 'symbol' in the cache.
Definition HWSymCache.h:56
LogicalResult verifyUnaryDynInstDataOp(Operation *)
Operation * getHierPathTopModule(Location loc, circt::hw::HWSymbolCache &symCache, FlatSymbolRefAttr pathSym)
Returns the top-level module which the given HierPathOp that defines pathSym, refers to.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition msft.py:1