CIRCT 20.0.0git
Loading...
Searching...
No Matches
FIRRTL.cpp
Go to the documentation of this file.
1//===- FIRRTL.cpp - C interface for the FIRRTL 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// This file implements the C-API for FIRRTL dialect.
10//
11//===----------------------------------------------------------------------===//
12
19#include "mlir/CAPI/IR.h"
20#include "mlir/CAPI/Registration.h"
21#include "mlir/CAPI/Support.h"
22#include "llvm/Support/JSON.h"
23
24using namespace circt;
25using namespace firrtl;
26
27namespace json = llvm::json;
28
29//===----------------------------------------------------------------------===//
30// Dialect API.
31//===----------------------------------------------------------------------===//
32
34 circt::firrtl::FIRRTLDialect)
35
36//===----------------------------------------------------------------------===//
37// Type API.
38//===----------------------------------------------------------------------===//
39
40bool firrtlTypeIsConst(MlirType type) { return isConst(unwrap(type)); }
41
42MlirType firrtlTypeGetConstType(MlirType type, bool isConst) {
43 return wrap(cast<FIRRTLBaseType>(unwrap(type)).getConstType(isConst));
44}
45
46int64_t firrtlTypeGetBitWidth(MlirType type, bool ignoreFlip) {
47 return getBitWidth(cast<FIRRTLBaseType>(unwrap(type)), ignoreFlip)
48 .value_or(-1);
49}
50
51bool firrtlTypeIsAUInt(MlirType type) { return isa<UIntType>(unwrap(type)); }
52
53MlirType firrtlTypeGetUInt(MlirContext ctx, int32_t width) {
54 return wrap(UIntType::get(unwrap(ctx), width));
55}
56
57bool firrtlTypeIsASInt(MlirType type) { return isa<SIntType>(unwrap(type)); }
58
59MlirType firrtlTypeGetSInt(MlirContext ctx, int32_t width) {
60 return wrap(SIntType::get(unwrap(ctx), width));
61}
62
63bool firrtlTypeIsAClock(MlirType type) { return isa<ClockType>(unwrap(type)); }
64
65MlirType firrtlTypeGetClock(MlirContext ctx) {
66 return wrap(ClockType::get(unwrap(ctx)));
67}
68
69bool firrtlTypeIsAReset(MlirType type) { return isa<ResetType>(unwrap(type)); }
70
71MlirType firrtlTypeGetReset(MlirContext ctx) {
72 return wrap(ResetType::get(unwrap(ctx)));
73}
74
75bool firrtlTypeIsAAsyncReset(MlirType type) {
76 return isa<AsyncResetType>(unwrap(type));
77}
78
79MlirType firrtlTypeGetAsyncReset(MlirContext ctx) {
80 return wrap(AsyncResetType::get(unwrap(ctx)));
81}
82
83bool firrtlTypeIsAAnalog(MlirType type) {
84 return isa<AnalogType>(unwrap(type));
85}
86
87MlirType firrtlTypeGetAnalog(MlirContext ctx, int32_t width) {
88 return wrap(AnalogType::get(unwrap(ctx), width));
89}
90
91bool firrtlTypeIsAVector(MlirType type) {
92 return isa<FVectorType>(unwrap(type));
93}
94
95MlirType firrtlTypeGetVector(MlirContext ctx, MlirType element, size_t count) {
96 auto baseType = cast<FIRRTLBaseType>(unwrap(element));
97 assert(baseType && "element must be base type");
98
99 return wrap(FVectorType::get(baseType, count));
100}
101
102MlirType firrtlTypeGetVectorElement(MlirType vec) {
103 return wrap(cast<FVectorType>(unwrap(vec)).getElementType());
104}
105
106size_t firrtlTypeGetVectorNumElements(MlirType vec) {
107 return cast<FVectorType>(unwrap(vec)).getNumElements();
108}
109
110bool firrtlTypeIsABundle(MlirType type) {
111 return isa<BundleType>(unwrap(type));
112}
113
114bool firrtlTypeIsAOpenBundle(MlirType type) {
115 return isa<OpenBundleType>(unwrap(type));
116}
117
118MlirType firrtlTypeGetBundle(MlirContext ctx, size_t count,
119 const FIRRTLBundleField *fields) {
120 bool bundleCompatible = true;
121 SmallVector<OpenBundleType::BundleElement, 4> bundleFields;
122
123 bundleFields.reserve(count);
124
125 for (size_t i = 0; i < count; i++) {
126 auto field = fields[i];
127 auto type = cast<FIRRTLType>(unwrap(field.type));
128 bundleFields.emplace_back(unwrap(field.name), field.isFlip, type);
129 bundleCompatible &= isa<BundleType::ElementType>(type);
130 }
131
132 // Try to emit base-only bundle.
133 if (bundleCompatible) {
134 auto bundleFieldsMapped = llvm::map_range(bundleFields, [](auto field) {
135 return BundleType::BundleElement{
136 field.name, field.isFlip, cast<BundleType::ElementType>(field.type)};
137 });
138 return wrap(
139 BundleType::get(unwrap(ctx), llvm::to_vector(bundleFieldsMapped)));
140 }
141 return wrap(OpenBundleType::get(unwrap(ctx), bundleFields));
142}
143
144size_t firrtlTypeGetBundleNumFields(MlirType bundle) {
145 if (auto bundleType = dyn_cast<BundleType>(unwrap(bundle))) {
146 return bundleType.getNumElements();
147 } else if (auto bundleType = dyn_cast<OpenBundleType>(unwrap(bundle))) {
148 return bundleType.getNumElements();
149 } else {
150 llvm_unreachable("must be a bundle type");
151 }
152}
153
154bool firrtlTypeGetBundleFieldByIndex(MlirType type, size_t index,
155 FIRRTLBundleField *field) {
156 auto unwrapped = unwrap(type);
157
158 auto cvt = [field](auto element) {
159 field->name = wrap(element.name);
160 field->isFlip = element.isFlip;
161 field->type = wrap(element.type);
162 };
163 if (auto bundleType = dyn_cast<BundleType>(unwrapped)) {
164 cvt(bundleType.getElement(index));
165 return true;
166 } else if (auto bundleType = dyn_cast<OpenBundleType>(unwrapped)) {
167 cvt(bundleType.getElement(index));
168 return true;
169 }
170 return false;
171}
172
173unsigned firrtlTypeGetBundleFieldIndex(MlirType type, MlirStringRef fieldName) {
174 std::optional<unsigned> fieldIndex;
175 if (auto bundleType = dyn_cast<BundleType>(unwrap(type))) {
176 fieldIndex = bundleType.getElementIndex(unwrap(fieldName));
177 } else if (auto bundleType = dyn_cast<OpenBundleType>(unwrap(type))) {
178 fieldIndex = bundleType.getElementIndex(unwrap(fieldName));
179 } else {
180 llvm_unreachable("must be a bundle type");
181 }
182 assert(fieldIndex.has_value() && "unknown field");
183 return fieldIndex.value();
184}
185
186bool firrtlTypeIsARef(MlirType type) { return isa<RefType>(unwrap(type)); }
187
188MlirType firrtlTypeGetRef(MlirType target, bool forceable) {
189 auto baseType = dyn_cast<FIRRTLBaseType>(unwrap(target));
190 assert(baseType && "target must be base type");
191
192 return wrap(RefType::get(baseType, forceable));
193}
194
195bool firrtlTypeIsAAnyRef(MlirType type) {
196 return isa<AnyRefType>(unwrap(type));
197}
198
199MlirType firrtlTypeGetAnyRef(MlirContext ctx) {
200 return wrap(AnyRefType::get(unwrap(ctx)));
201}
202
203bool firrtlTypeIsAInteger(MlirType type) {
204 return isa<FIntegerType>(unwrap(type));
205}
206
207MlirType firrtlTypeGetInteger(MlirContext ctx) {
208 return wrap(FIntegerType::get(unwrap(ctx)));
209}
210
211bool firrtlTypeIsADouble(MlirType type) {
212 return isa<DoubleType>(unwrap(type));
213}
214
215MlirType firrtlTypeGetDouble(MlirContext ctx) {
216 return wrap(DoubleType::get(unwrap(ctx)));
217}
218
219bool firrtlTypeIsAString(MlirType type) {
220 return isa<StringType>(unwrap(type));
221}
222
223MlirType firrtlTypeGetString(MlirContext ctx) {
224 return wrap(StringType::get(unwrap(ctx)));
225}
226
227bool firrtlTypeIsABoolean(MlirType type) { return isa<BoolType>(unwrap(type)); }
228
229MlirType firrtlTypeGetBoolean(MlirContext ctx) {
230 return wrap(BoolType::get(unwrap(ctx)));
231}
232
233bool firrtlTypeIsAPath(MlirType type) { return isa<PathType>(unwrap(type)); }
234
235MlirType firrtlTypeGetPath(MlirContext ctx) {
236 return wrap(PathType::get(unwrap(ctx)));
237}
238
239bool firrtlTypeIsAList(MlirType type) { return isa<ListType>(unwrap(type)); }
240
241MlirType firrtlTypeGetList(MlirContext ctx, MlirType elementType) {
242 auto type = dyn_cast<PropertyType>(unwrap(elementType));
243 assert(type && "element must be property type");
244
245 return wrap(ListType::get(unwrap(ctx), type));
246}
247
248bool firrtlTypeIsAClass(MlirType type) { return isa<ClassType>(unwrap(type)); }
249
250MlirType firrtlTypeGetClass(MlirContext ctx, MlirAttribute name,
251 size_t numberOfElements,
252 const FIRRTLClassElement *elements) {
253 auto nameSymbol = dyn_cast<FlatSymbolRefAttr>(unwrap(name));
254 assert(nameSymbol && "name must be FlatSymbolRefAttr");
255
256 SmallVector<ClassElement, 4> classElements;
257 classElements.reserve(numberOfElements);
258
259 for (size_t i = 0; i < numberOfElements; i++) {
260 auto element = elements[i];
261 auto dir = element.direction == FIRRTL_DIRECTION_IN ? Direction::In
262 : Direction::Out;
263 classElements.emplace_back(unwrap(element.name), unwrap(element.type), dir);
264 }
265 return wrap(ClassType::get(unwrap(ctx), nameSymbol, classElements));
266}
267
268MlirType firrtlTypeGetMaskType(MlirType type) {
269 auto baseType = type_dyn_cast<FIRRTLBaseType>(unwrap(type));
270 assert(baseType && "unexpected type, must be base type");
271 return wrap(baseType.getMaskType());
272}
273
274//===----------------------------------------------------------------------===//
275// Attribute API.
276//===----------------------------------------------------------------------===//
277
278MlirAttribute firrtlAttrGetConvention(MlirContext ctx,
279 FIRRTLConvention convention) {
280 Convention value;
281
282 switch (convention) {
284 value = Convention::Internal;
285 break;
287 value = Convention::Scalarized;
288 break;
289 }
290
291 return wrap(ConventionAttr::get(unwrap(ctx), value));
292}
293
294MlirAttribute firrtlAttrGetLayerConvention(MlirContext ctx,
295 FIRRTLLayerConvention convention) {
296 LayerConvention value;
297
298 switch (convention) {
300 value = LayerConvention::Bind;
301 break;
303 value = LayerConvention::Inline;
304 break;
305 }
306
307 return wrap(LayerConventionAttr::get(unwrap(ctx), value));
308}
309
310MlirAttribute firrtlAttrGetPortDirs(MlirContext ctx, size_t count,
311 const FIRRTLDirection *dirs) {
312 static_assert(FIRRTL_DIRECTION_IN ==
313 static_cast<std::underlying_type_t<Direction>>(Direction::In));
314 static_assert(FIRRTL_DIRECTION_OUT ==
315 static_cast<std::underlying_type_t<Direction>>(Direction::Out));
316
317 // FIXME: The `reinterpret_cast` here may voilate strict aliasing rule. Is
318 // there a better way?
320 unwrap(ctx), ArrayRef(reinterpret_cast<const Direction *>(dirs), count)));
321}
322
323MlirAttribute firrtlAttrGetParamDecl(MlirContext ctx, MlirIdentifier name,
324 MlirType type, MlirAttribute value) {
325 return wrap(ParamDeclAttr::get(unwrap(ctx), unwrap(name), unwrap(type),
326 unwrap(value)));
327}
328
329MlirAttribute firrtlAttrGetNameKind(MlirContext ctx, FIRRTLNameKind nameKind) {
330 NameKindEnum value;
331
332 switch (nameKind) {
334 value = NameKindEnum::DroppableName;
335 break;
337 value = NameKindEnum::InterestingName;
338 break;
339 }
340
341 return wrap(NameKindEnumAttr::get(unwrap(ctx), value));
342}
343
344MlirAttribute firrtlAttrGetRUW(MlirContext ctx, FIRRTLRUW ruw) {
345 RUWAttr value;
346
347 switch (ruw) {
349 value = RUWAttr::Undefined;
350 break;
351 case FIRRTL_RUW_OLD:
352 value = RUWAttr::Old;
353 break;
354 case FIRRTL_RUW_NEW:
355 value = RUWAttr::New;
356 break;
357 }
358
359 return wrap(RUWAttrAttr::get(unwrap(ctx), value));
360}
361
362MlirAttribute firrtlAttrGetMemInit(MlirContext ctx, MlirIdentifier filename,
363 bool isBinary, bool isInline) {
364 return wrap(
365 MemoryInitAttr::get(unwrap(ctx), unwrap(filename), isBinary, isInline));
366}
367
368MlirAttribute firrtlAttrGetMemDir(MlirContext ctx, FIRRTLMemDir dir) {
369 MemDirAttr value;
370
371 switch (dir) {
373 value = MemDirAttr::Infer;
374 break;
376 value = MemDirAttr::Read;
377 break;
379 value = MemDirAttr::Write;
380 break;
382 value = MemDirAttr::ReadWrite;
383 break;
384 }
385
386 return wrap(MemDirAttrAttr::get(unwrap(ctx), value));
387}
388
389MlirAttribute firrtlAttrGetEventControl(MlirContext ctx,
390 FIRRTLEventControl eventControl) {
391 EventControl value;
392
393 switch (eventControl) {
395 value = EventControl::AtPosEdge;
396 break;
398 value = EventControl::AtNegEdge;
399 break;
401 value = EventControl::AtEdge;
402 break;
403 }
404
405 return wrap(EventControlAttr::get(unwrap(ctx), value));
406}
407
408MlirAttribute firrtlAttrGetIntegerFromString(MlirType type, unsigned numBits,
409 MlirStringRef str, uint8_t radix) {
410 auto value = APInt{numBits, unwrap(str), radix};
411 return wrap(IntegerAttr::get(unwrap(type), value));
412}
413
415 Flow flowValue;
416
417 switch (flow) {
419 flowValue = Flow::None;
420 break;
422 flowValue = Flow::Source;
423 break;
425 flowValue = Flow::Sink;
426 break;
428 flowValue = Flow::Duplex;
429 break;
430 }
431
432 auto flowResult = firrtl::foldFlow(unwrap(value), flowValue);
433
434 switch (flowResult) {
435 case Flow::None:
437 case Flow::Source:
439 case Flow::Sink:
441 case Flow::Duplex:
443 }
444 llvm_unreachable("invalid flow");
445}
446
448 MlirContext ctx, MlirStringRef annotationsStr,
449 MlirAttribute *importedAnnotationsArray) {
450 auto annotations = json::parse(unwrap(annotationsStr));
451 if (!annotations) {
452 return false;
453 }
454
455 auto *ctxUnwrapped = unwrap(ctx);
456
457 json::Path::Root root;
458 SmallVector<Attribute> annos;
459 if (!importAnnotationsFromJSONRaw(annotations.get(), annos, root,
460 ctxUnwrapped)) {
461 return false;
462 }
463
464 *importedAnnotationsArray = wrap(ArrayAttr::get(ctxUnwrapped, annos));
465 return true;
466}
assert(baseType &&"element must be base type")
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
MlirType elementType
Definition CHIRRTL.cpp:29
bool firrtlTypeIsAUInt(MlirType type)
Checks if this type is a unsigned integer type.
Definition FIRRTL.cpp:51
bool firrtlTypeIsASInt(MlirType type)
Checks if this type is a signed integer type.
Definition FIRRTL.cpp:57
bool firrtlTypeIsARef(MlirType type)
Checks if this type is a ref type.
Definition FIRRTL.cpp:186
bool firrtlTypeIsAString(MlirType type)
Checks if this type is a property string type.
Definition FIRRTL.cpp:219
MlirAttribute firrtlAttrGetMemDir(MlirContext ctx, FIRRTLMemDir dir)
Creates a MemDirAttr with the specified memory port direction.
Definition FIRRTL.cpp:368
MlirType firrtlTypeGetAsyncReset(MlirContext ctx)
Creates an async reset type.
Definition FIRRTL.cpp:79
MlirType firrtlTypeGetList(MlirContext ctx, MlirType elementType)
Creates a property list type with the specified element type.
Definition FIRRTL.cpp:241
bool firrtlTypeIsAClass(MlirType type)
Checks if this type is a class type.
Definition FIRRTL.cpp:248
bool firrtlTypeGetBundleFieldByIndex(MlirType type, size_t index, FIRRTLBundleField *field)
Returns the field at the specified index in the bundle type.
Definition FIRRTL.cpp:154
MlirAttribute firrtlAttrGetIntegerFromString(MlirType type, unsigned numBits, MlirStringRef str, uint8_t radix)
Creates an IntegerAttr from a string representation of integer.
Definition FIRRTL.cpp:408
MlirType firrtlTypeGetBoolean(MlirContext ctx)
Creates a property boolean type.
Definition FIRRTL.cpp:229
MlirType firrtlTypeGetDouble(MlirContext ctx)
Creates a property double type.
Definition FIRRTL.cpp:215
MlirType firrtlTypeGetPath(MlirContext ctx)
Creates a property path type.
Definition FIRRTL.cpp:235
MlirType firrtlTypeGetConstType(MlirType type, bool isConst)
Returns a const or non-const version of this type.
Definition FIRRTL.cpp:42
MlirType firrtlTypeGetString(MlirContext ctx)
Creates a property string type.
Definition FIRRTL.cpp:223
bool firrtlTypeIsAClock(MlirType type)
Checks if this type is a clock type.
Definition FIRRTL.cpp:63
MlirType firrtlTypeGetAnalog(MlirContext ctx, int32_t width)
Creates an analog type with the specified width.
Definition FIRRTL.cpp:87
MlirType firrtlTypeGetInteger(MlirContext ctx)
Creates a property integer type.
Definition FIRRTL.cpp:207
bool firrtlTypeIsAInteger(MlirType type)
Checks if this type is a property integer type.
Definition FIRRTL.cpp:203
MlirAttribute firrtlAttrGetConvention(MlirContext ctx, FIRRTLConvention convention)
Creates an ConventionAttr with the specified value.
Definition FIRRTL.cpp:278
MlirType firrtlTypeGetClock(MlirContext ctx)
Creates a clock type.
Definition FIRRTL.cpp:65
MlirAttribute firrtlAttrGetLayerConvention(MlirContext ctx, FIRRTLLayerConvention convention)
Creates a LayerConventionAttr with the specified value.
Definition FIRRTL.cpp:294
MlirType firrtlTypeGetReset(MlirContext ctx)
Creates a reset type.
Definition FIRRTL.cpp:71
bool firrtlTypeIsABundle(MlirType type)
Returns true if the specified type is a bundle type.
Definition FIRRTL.cpp:110
MlirType firrtlTypeGetVector(MlirContext ctx, MlirType element, size_t count)
Creates a vector type with the specified element type and count.
Definition FIRRTL.cpp:95
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(FIRRTL, firrtl, circt::firrtl::FIRRTLDialect) bool firrtlTypeIsConst(MlirType type)
Definition FIRRTL.cpp:33
bool firrtlImportAnnotationsFromJSONRaw(MlirContext ctx, MlirStringRef annotationsStr, MlirAttribute *importedAnnotationsArray)
Deserializes a JSON value into FIRRTL Annotations.
Definition FIRRTL.cpp:447
bool firrtlTypeIsAPath(MlirType type)
Checks if this type is a property path type.
Definition FIRRTL.cpp:233
MlirType firrtlTypeGetUInt(MlirContext ctx, int32_t width)
Creates a unsigned integer type with the specified width.
Definition FIRRTL.cpp:53
MlirType firrtlTypeGetAnyRef(MlirContext ctx)
Creates an anyref type.
Definition FIRRTL.cpp:199
MlirAttribute firrtlAttrGetPortDirs(MlirContext ctx, size_t count, const FIRRTLDirection *dirs)
Creates a DenseBoolArrayAttr with the specified port directions.
Definition FIRRTL.cpp:310
bool firrtlTypeIsAReset(MlirType type)
Checks if this type is a reset type.
Definition FIRRTL.cpp:69
MlirType firrtlTypeGetClass(MlirContext ctx, MlirAttribute name, size_t numberOfElements, const FIRRTLClassElement *elements)
Creates a class type with the specified name and elements.
Definition FIRRTL.cpp:250
bool firrtlTypeIsAAnyRef(MlirType type)
Checks if this type is an anyref type.
Definition FIRRTL.cpp:195
bool firrtlTypeIsAOpenBundle(MlirType type)
Returns true if the specified type is an open bundle type.
Definition FIRRTL.cpp:114
MlirType firrtlTypeGetMaskType(MlirType type)
Returns this type with all ground types replaced with UInt<1>.
Definition FIRRTL.cpp:268
MlirType firrtlTypeGetSInt(MlirContext ctx, int32_t width)
Creates a signed integer type with the specified width.
Definition FIRRTL.cpp:59
MlirType firrtlTypeGetRef(MlirType target, bool forceable)
Creates a ref type.
Definition FIRRTL.cpp:188
MlirType firrtlTypeGetBundle(MlirContext ctx, size_t count, const FIRRTLBundleField *fields)
Creates a bundle type with the specified fields.
Definition FIRRTL.cpp:118
bool firrtlTypeIsAVector(MlirType type)
Checks if this type is a vector type.
Definition FIRRTL.cpp:91
int64_t firrtlTypeGetBitWidth(MlirType type, bool ignoreFlip)
Gets the bit width for this type, returns -1 if unknown.
Definition FIRRTL.cpp:46
MlirType firrtlTypeGetVectorElement(MlirType vec)
Returns the element type of a vector type.
Definition FIRRTL.cpp:102
MlirAttribute firrtlAttrGetEventControl(MlirContext ctx, FIRRTLEventControl eventControl)
Creates a EventControlAttr with the specified value.
Definition FIRRTL.cpp:389
bool firrtlTypeIsADouble(MlirType type)
Checks if this type is a property double type.
Definition FIRRTL.cpp:211
bool firrtlTypeIsAList(MlirType type)
Checks if this type is a property list type.
Definition FIRRTL.cpp:239
MlirAttribute firrtlAttrGetParamDecl(MlirContext ctx, MlirIdentifier name, MlirType type, MlirAttribute value)
Creates a ParamDeclAttr with the specified name, type, and value.
Definition FIRRTL.cpp:323
MlirAttribute firrtlAttrGetMemInit(MlirContext ctx, MlirIdentifier filename, bool isBinary, bool isInline)
Creates a MemoryInitAttr with the specified memory initialization information.
Definition FIRRTL.cpp:362
FIRRTLValueFlow firrtlValueFoldFlow(MlirValue value, FIRRTLValueFlow flow)
Computes the flow for a Value, value, as determined by the FIRRTL specification.
Definition FIRRTL.cpp:414
MlirAttribute firrtlAttrGetRUW(MlirContext ctx, FIRRTLRUW ruw)
Creates a RUWAttr with the specified Read-Under-Write Behaviour.
Definition FIRRTL.cpp:344
bool firrtlTypeIsAAsyncReset(MlirType type)
Checks if this type is an async reset type.
Definition FIRRTL.cpp:75
MlirAttribute firrtlAttrGetNameKind(MlirContext ctx, FIRRTLNameKind nameKind)
Creates a NameKindEnumAttr with the specified name preservation semantic.
Definition FIRRTL.cpp:329
bool firrtlTypeIsAAnalog(MlirType type)
Checks if this type is an analog type.
Definition FIRRTL.cpp:83
bool firrtlTypeIsABoolean(MlirType type)
Checks if this type is a property boolean type.
Definition FIRRTL.cpp:227
size_t firrtlTypeGetVectorNumElements(MlirType vec)
Returns the number of elements in a vector type.
Definition FIRRTL.cpp:106
unsigned firrtlTypeGetBundleFieldIndex(MlirType type, MlirStringRef fieldName)
Returns the index of the field with the specified name in the bundle type.
Definition FIRRTL.cpp:173
size_t firrtlTypeGetBundleNumFields(MlirType bundle)
Returns the number of fields in the bundle type.
Definition FIRRTL.cpp:144
MLIR_CAPI_EXPORTED bool firrtlTypeIsConst(MlirType type)
Returns true if this is a const type whose value is guaranteed to be unchanging at circuit execution ...
FIRRTLLayerConvention
Layer lowering conventions.
Definition FIRRTL.h:34
@ FIRRTL_LAYER_CONVENTION_INLINE
Definition FIRRTL.h:36
@ FIRRTL_LAYER_CONVENTION_BIND
Definition FIRRTL.h:35
FIRRTLValueFlow
Flow of value.
Definition FIRRTL.h:82
@ FIRRTL_VALUE_FLOW_SOURCE
Definition FIRRTL.h:84
@ FIRRTL_VALUE_FLOW_NONE
Definition FIRRTL.h:83
@ FIRRTL_VALUE_FLOW_SINK
Definition FIRRTL.h:85
@ FIRRTL_VALUE_FLOW_DUPLEX
Definition FIRRTL.h:86
FIRRTLNameKind
Name preservation.
Definition FIRRTL.h:50
@ FIRRTL_NAME_KIND_DROPPABLE_NAME
Definition FIRRTL.h:51
@ FIRRTL_NAME_KIND_INTERESTING_NAME
Definition FIRRTL.h:52
FIRRTLMemDir
Memory port direction.
Definition FIRRTL.h:65
@ FIRRTL_MEM_DIR_INFER
Definition FIRRTL.h:66
@ FIRRTL_MEM_DIR_READ
Definition FIRRTL.h:67
@ FIRRTL_MEM_DIR_READ_WRITE
Definition FIRRTL.h:69
@ FIRRTL_MEM_DIR_WRITE
Definition FIRRTL.h:68
FIRRTLEventControl
Edge control trigger.
Definition FIRRTL.h:74
@ FIRRTL_EVENT_CONTROL_AT_POS_EDGE
Definition FIRRTL.h:75
@ FIRRTL_EVENT_CONTROL_AT_NEG_EDGE
Definition FIRRTL.h:76
@ FIRRTL_EVENT_CONTROL_AT_EDGE
Definition FIRRTL.h:77
FIRRTLDirection
Port direction.
Definition FIRRTL.h:41
@ FIRRTL_DIRECTION_OUT
Definition FIRRTL.h:43
@ FIRRTL_DIRECTION_IN
Definition FIRRTL.h:42
FIRRTLRUW
Read-Under-Write behaviour.
Definition FIRRTL.h:57
@ FIRRTL_RUW_OLD
Definition FIRRTL.h:59
@ FIRRTL_RUW_UNDEFINED
Definition FIRRTL.h:58
@ FIRRTL_RUW_NEW
Definition FIRRTL.h:60
FIRRTLConvention
Module instantiation conventions.
Definition FIRRTL.h:27
@ FIRRTL_CONVENTION_SCALARIZED
Definition FIRRTL.h:29
@ FIRRTL_CONVENTION_INTERNAL
Definition FIRRTL.h:28
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Definition OM.cpp:113
mlir::DenseBoolArrayAttr packAttribute(MLIRContext *context, ArrayRef< Direction > directions)
Return a DenseBoolArrayAttr containing the packed representation of an array of directions.
Direction
This represents the direction of a single port.
Flow foldFlow(Value val, Flow accumulatedFlow=Flow::Source)
Compute the flow for a Value, val, as determined by the FIRRTL specification.
bool isConst(Type type)
Returns true if this is a 'const' type whose value is guaranteed to be unchanging at circuit executio...
bool importAnnotationsFromJSONRaw(llvm::json::Value &value, SmallVectorImpl< Attribute > &annotations, llvm::json::Path path, MLIRContext *context)
Deserialize a JSON value into FIRRTL Annotations.
std::optional< int64_t > getBitWidth(FIRRTLBaseType type, bool ignoreFlip=false)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Describes a field in a bundle type.
Definition FIRRTL.h:91
MlirType type
Definition FIRRTL.h:94
MlirIdentifier name
Definition FIRRTL.h:92
Describes an element in a class type.
Definition FIRRTL.h:99
FIRRTLDirection direction
Definition FIRRTL.h:102