CIRCT 20.0.0git
Loading...
Searching...
No Matches
KanagawaTypes.cpp
Go to the documentation of this file.
1//===- KanagawaTypes.cpp - Implementation of Kanagawa dialect types -------===//
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
12#include "mlir/IR/DialectImplementation.h"
13#include "llvm/ADT/StringExtras.h"
14#include "llvm/ADT/StringSwitch.h"
15#include "llvm/ADT/TypeSwitch.h"
16
17using namespace circt;
18using namespace kanagawa;
19
21 auto scopeRef = dyn_cast<ScopeRefType>(type);
22 if (!scopeRef)
23 return false;
24
25 return scopeRef.isOpaque();
26}
27
28Type ScopeRefType::parse(AsmParser &p) {
29 if (p.parseOptionalLess())
30 return ScopeRefType::get(p.getBuilder().getContext());
31
32 SymbolRefAttr attr;
33 if (p.parseAttribute(attr) || p.parseGreater())
34 return Type();
35 if (attr.getNestedReferences().size() != 1) {
36 p.emitError(p.getNameLoc(), "expected @outer::@inner format");
37 return Type();
38 }
39 return ScopeRefType::get(
40 p.getBuilder().getContext(),
41 hw::InnerRefAttr::get(attr.getRootReference(), attr.getLeafReference()));
42}
43
44void ScopeRefType::print(AsmPrinter &p) const {
45 if (auto ref = getScopeRef())
46 ref.print(p);
47}
48
49#define GET_TYPEDEF_CLASSES
50#include "circt/Dialect/Kanagawa/KanagawaTypes.cpp.inc"
51
52void KanagawaDialect::registerTypes() {
53 // Register types.
54 addTypes<
55#define GET_TYPEDEF_LIST
56#include "circt/Dialect/Kanagawa/KanagawaTypes.cpp.inc"
57 >();
58}
bool isOpaqueScopeRefType(mlir::Type type)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.