CIRCT  20.0.0git
RTG.cpp
Go to the documentation of this file.
1 //===- RTG.cpp - C interface for the RTG dialect --------------------------===//
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 #include "circt-c/Dialect/RTG.h"
12 
13 #include "mlir/CAPI/Registration.h"
14 
15 using namespace circt;
16 using namespace circt::rtg;
17 
18 //===----------------------------------------------------------------------===//
19 // Dialect API.
20 //===----------------------------------------------------------------------===//
21 
23 
24 //===----------------------------------------------------------------------===//
25 // Type API.
26 //===----------------------------------------------------------------------===//
27 
28 // SequenceType
29 //===----------------------------------------------------------------------===//
30 
31 bool rtgTypeIsASequence(MlirType type) {
32  return isa<SequenceType>(unwrap(type));
33 }
34 
35 MlirType rtgSequenceTypeGet(MlirContext ctxt) {
37 }
38 
39 // LabelType
40 //===----------------------------------------------------------------------===//
41 
42 bool rtgTypeIsALabel(MlirType type) { return isa<LabelType>(unwrap(type)); }
43 
44 MlirType rtgLabelTypeGet(MlirContext ctxt) {
45  return wrap(LabelType::get(unwrap(ctxt)));
46 }
47 
48 // SetType
49 //===----------------------------------------------------------------------===//
50 
51 bool rtgTypeIsASet(MlirType type) { return isa<SetType>(unwrap(type)); }
52 
53 MlirType rtgSetTypeGet(MlirType elementType) {
54  auto ty = unwrap(elementType);
55  return wrap(SetType::get(ty.getContext(), ty));
56 }
57 
58 // BagType
59 //===----------------------------------------------------------------------===//
60 
61 bool rtgTypeIsABag(MlirType type) { return isa<BagType>(unwrap(type)); }
62 
63 MlirType rtgBagTypeGet(MlirType elementType) {
64  auto ty = unwrap(elementType);
65  return wrap(BagType::get(ty.getContext(), ty));
66 }
67 
68 // DictType
69 //===----------------------------------------------------------------------===//
70 
71 bool rtgTypeIsADict(MlirType type) { return isa<DictType>(unwrap(type)); }
72 
73 MlirType rtgDictTypeGet(MlirContext ctxt, intptr_t numEntries,
74  MlirAttribute const *entryNames,
75  MlirType const *entryTypes) {
76  SmallVector<DictEntry> entries;
77  for (unsigned i = 0; i < numEntries; ++i) {
78  DictEntry entry;
79  entry.name = cast<StringAttr>(unwrap(entryNames[i]));
80  entry.type = unwrap(entryTypes[i]);
81  entries.emplace_back(entry);
82  }
83  return wrap(DictType::get(unwrap(ctxt), entries));
84 }
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
MlirType elementType
Definition: CHIRRTL.cpp:29
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(CHIRRTL, chirrtl, circt::chirrtl::CHIRRTLDialect) MlirType chirrtlTypeGetCMemory(MlirContext ctx
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition: OM.cpp:113
bool rtgTypeIsABag(MlirType type)
If the type is an RTG bag.
Definition: RTG.cpp:61
MlirType rtgSetTypeGet(MlirType elementType)
Creates an RTG set type in the context.
Definition: RTG.cpp:53
MlirType rtgSequenceTypeGet(MlirContext ctxt)
Creates an RTG sequence type in the context.
Definition: RTG.cpp:35
bool rtgTypeIsASet(MlirType type)
If the type is an RTG set.
Definition: RTG.cpp:51
bool rtgTypeIsADict(MlirType type)
If the type is an RTG dict.
Definition: RTG.cpp:71
bool rtgTypeIsALabel(MlirType type)
If the type is an RTG label.
Definition: RTG.cpp:42
MlirType rtgDictTypeGet(MlirContext ctxt, intptr_t numEntries, MlirAttribute const *entryNames, MlirType const *entryTypes)
Creates an RTG dict type in the context.
Definition: RTG.cpp:73
bool rtgTypeIsASequence(MlirType type)
If the type is an RTG sequence.
Definition: RTG.cpp:31
MlirType rtgBagTypeGet(MlirType elementType)
Creates an RTG bag type in the context.
Definition: RTG.cpp:63
MlirType rtgLabelTypeGet(MlirContext ctxt)
Creates an RTG mode type in the context.
Definition: RTG.cpp:44
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
Definition: CalyxOps.cpp:55
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: rtg.py:1
Defines an entry in an !rtg.dict.
Definition: RTGTypes.h:20
mlir::Type type
Definition: RTGTypes.h:22
mlir::StringAttr name
Definition: RTGTypes.h:21