CIRCT  19.0.0git
IbisTypes.cpp
Go to the documentation of this file.
1 //===- IbisTypes.cpp - Implementation of Ibis 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 
17 using namespace circt;
18 using namespace ibis;
19 
20 bool circt::ibis::isOpaqueScopeRefType(mlir::Type type) {
21  auto scopeRef = type.dyn_cast<ScopeRefType>();
22  if (!scopeRef)
23  return false;
24 
25  return scopeRef.isOpaque();
26 }
27 
28 Type 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 
44 void 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/Ibis/IbisTypes.cpp.inc"
51 
52 void IbisDialect::registerTypes() {
53  // Register types.
54  addTypes<
55 #define GET_TYPEDEF_LIST
56 #include "circt/Dialect/Ibis/IbisTypes.cpp.inc"
57  >();
58 }
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
Definition: CalyxOps.cpp:54
bool isOpaqueScopeRefType(mlir::Type type)
Definition: IbisTypes.cpp:20
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
Definition: DebugAnalysis.h:21