CIRCT 23.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
195MlirType firrtlTypeGetColoredRef(MlirType target, bool forceable,
196 MlirAttribute layer) {
197 auto baseType = dyn_cast<FIRRTLBaseType>(unwrap(target));
198 assert(baseType && "target must be base type");
199 auto layerAttr = dyn_cast<SymbolRefAttr>(unwrap(layer));
200 assert(layerAttr && "layer must be symbol ref attribute");
201
202 return wrap(RefType::get(baseType, forceable, layerAttr));
203}
204
205bool firrtlTypeIsAAnyRef(MlirType type) {
206 return isa<AnyRefType>(unwrap(type));
207}
208
209MlirType firrtlTypeGetAnyRef(MlirContext ctx) {
210 return wrap(AnyRefType::get(unwrap(ctx)));
211}
212
213bool firrtlTypeIsAInteger(MlirType type) {
214 return isa<FIntegerType>(unwrap(type));
215}
216
217MlirType firrtlTypeGetInteger(MlirContext ctx) {
218 return wrap(FIntegerType::get(unwrap(ctx)));
219}
220
221bool firrtlTypeIsADouble(MlirType type) {
222 return isa<DoubleType>(unwrap(type));
223}
224
225MlirType firrtlTypeGetDouble(MlirContext ctx) {
226 return wrap(DoubleType::get(unwrap(ctx)));
227}
228
229bool firrtlTypeIsAString(MlirType type) {
230 return isa<StringType>(unwrap(type));
231}
232
233MlirType firrtlTypeGetString(MlirContext ctx) {
234 return wrap(StringType::get(unwrap(ctx)));
235}
236
237bool firrtlTypeIsABoolean(MlirType type) { return isa<BoolType>(unwrap(type)); }
238
239MlirType firrtlTypeGetBoolean(MlirContext ctx) {
240 return wrap(BoolType::get(unwrap(ctx)));
241}
242
243bool firrtlTypeIsAPath(MlirType type) { return isa<PathType>(unwrap(type)); }
244
245MlirType firrtlTypeGetPath(MlirContext ctx) {
246 return wrap(PathType::get(unwrap(ctx)));
247}
248
249bool firrtlTypeIsAList(MlirType type) { return isa<ListType>(unwrap(type)); }
250
251MlirType firrtlTypeGetList(MlirContext ctx, MlirType elementType) {
252 auto type = dyn_cast<PropertyType>(unwrap(elementType));
253 assert(type && "element must be property type");
254
255 return wrap(ListType::get(unwrap(ctx), type));
256}
257
258bool firrtlTypeIsAClass(MlirType type) { return isa<ClassType>(unwrap(type)); }
259
260MlirType firrtlTypeGetClass(MlirContext ctx, MlirAttribute name,
261 size_t numberOfElements,
262 const FIRRTLClassElement *elements) {
263 auto nameSymbol = dyn_cast<FlatSymbolRefAttr>(unwrap(name));
264 assert(nameSymbol && "name must be FlatSymbolRefAttr");
265
266 SmallVector<ClassElement, 4> classElements;
267 classElements.reserve(numberOfElements);
268
269 for (size_t i = 0; i < numberOfElements; i++) {
270 auto element = elements[i];
271 auto dir = element.direction == FIRRTL_DIRECTION_IN ? Direction::In
272 : Direction::Out;
273 classElements.emplace_back(unwrap(element.name), unwrap(element.type), dir);
274 }
275 return wrap(ClassType::get(unwrap(ctx), nameSymbol, classElements));
276}
277
278MlirType firrtlTypeGetMaskType(MlirType type) {
279 auto baseType = type_dyn_cast<FIRRTLBaseType>(unwrap(type));
280 assert(baseType && "unexpected type, must be base type");
281 return wrap(baseType.getMaskType());
282}
283
284//===----------------------------------------------------------------------===//
285// Attribute API.
286//===----------------------------------------------------------------------===//
287
288MlirAttribute firrtlAttrGetConvention(MlirContext ctx,
289 FIRRTLConvention convention) {
290 Convention value;
291
292 switch (convention) {
294 value = Convention::Internal;
295 break;
297 value = Convention::Scalarized;
298 break;
299 }
300
301 return wrap(ConventionAttr::get(unwrap(ctx), value));
302}
303
304MlirAttribute firrtlAttrGetLayerConvention(MlirContext ctx,
305 FIRRTLLayerConvention convention) {
306 LayerConvention value;
307
308 switch (convention) {
310 value = LayerConvention::Bind;
311 break;
313 value = LayerConvention::Inline;
314 break;
315 }
316
317 return wrap(LayerConventionAttr::get(unwrap(ctx), value));
318}
319
320MlirAttribute firrtlAttrGetPortDirs(MlirContext ctx, size_t count,
321 const FIRRTLDirection *dirs) {
322 static_assert(FIRRTL_DIRECTION_IN ==
323 static_cast<std::underlying_type_t<Direction>>(Direction::In));
324 static_assert(FIRRTL_DIRECTION_OUT ==
325 static_cast<std::underlying_type_t<Direction>>(Direction::Out));
326
327 // FIXME: The `reinterpret_cast` here may voilate strict aliasing rule. Is
328 // there a better way?
330 unwrap(ctx), ArrayRef(reinterpret_cast<const Direction *>(dirs), count)));
331}
332
333MlirAttribute firrtlAttrGetParamDecl(MlirContext ctx, MlirIdentifier name,
334 MlirType type, MlirAttribute value) {
335 return wrap(ParamDeclAttr::get(unwrap(ctx), unwrap(name), unwrap(type),
336 unwrap(value)));
337}
338
339MlirAttribute firrtlAttrGetNameKind(MlirContext ctx, FIRRTLNameKind nameKind) {
340 NameKindEnum value;
341
342 switch (nameKind) {
344 value = NameKindEnum::DroppableName;
345 break;
347 value = NameKindEnum::InterestingName;
348 break;
349 }
350
351 return wrap(NameKindEnumAttr::get(unwrap(ctx), value));
352}
353
354MlirAttribute firrtlAttrGetRUW(MlirContext ctx, FIRRTLRUW ruw) {
355 RUWBehavior value;
356
357 switch (ruw) {
359 value = RUWBehavior::Undefined;
360 break;
361 case FIRRTL_RUW_OLD:
362 value = RUWBehavior::Old;
363 break;
364 case FIRRTL_RUW_NEW:
365 value = RUWBehavior::New;
366 break;
367 }
368
369 return wrap(RUWBehaviorAttr::get(unwrap(ctx), value));
370}
371
372MlirAttribute firrtlAttrGetMemInit(MlirContext ctx, MlirIdentifier filename,
373 bool isBinary, bool isInline) {
374 return wrap(
375 MemoryInitAttr::get(unwrap(ctx), unwrap(filename), isBinary, isInline));
376}
377
378MlirAttribute firrtlAttrGetMemDir(MlirContext ctx, FIRRTLMemDir dir) {
379 MemDirAttr value;
380
381 switch (dir) {
383 value = MemDirAttr::Infer;
384 break;
386 value = MemDirAttr::Read;
387 break;
389 value = MemDirAttr::Write;
390 break;
392 value = MemDirAttr::ReadWrite;
393 break;
394 }
395
396 return wrap(MemDirAttrAttr::get(unwrap(ctx), value));
397}
398
399MlirAttribute firrtlAttrGetEventControl(MlirContext ctx,
400 FIRRTLEventControl eventControl) {
401 EventControl value;
402
403 switch (eventControl) {
405 value = EventControl::AtPosEdge;
406 break;
408 value = EventControl::AtNegEdge;
409 break;
411 value = EventControl::AtEdge;
412 break;
413 }
414
415 return wrap(EventControlAttr::get(unwrap(ctx), value));
416}
417
418MlirAttribute firrtlAttrGetIntegerFromString(MlirType type, unsigned numBits,
419 MlirStringRef str, uint8_t radix) {
420 auto value = APInt{numBits, unwrap(str), radix};
421 return wrap(IntegerAttr::get(unwrap(type), value));
422}
423
425 Flow flowValue;
426
427 switch (flow) {
429 flowValue = Flow::None;
430 break;
432 flowValue = Flow::Source;
433 break;
435 flowValue = Flow::Sink;
436 break;
438 flowValue = Flow::Duplex;
439 break;
440 }
441
442 auto flowResult = firrtl::foldFlow(unwrap(value), flowValue);
443
444 switch (flowResult) {
445 case Flow::None:
447 case Flow::Source:
449 case Flow::Sink:
451 case Flow::Duplex:
453 }
454 llvm_unreachable("invalid flow");
455}
456
458 MlirContext ctx, MlirStringRef annotationsStr,
459 MlirAttribute *importedAnnotationsArray) {
460 auto annotations = json::parse(unwrap(annotationsStr));
461 if (!annotations) {
462 return false;
463 }
464
465 auto *ctxUnwrapped = unwrap(ctx);
466
467 json::Path::Root root;
468 SmallVector<Attribute> annos;
469 if (!importAnnotationsFromJSONRaw(annotations.get(), annos, root,
470 ctxUnwrapped)) {
471 return false;
472 }
473
474 *importedAnnotationsArray = wrap(ArrayAttr::get(ctxUnwrapped, annos));
475 return true;
476}
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:229
MlirAttribute firrtlAttrGetMemDir(MlirContext ctx, FIRRTLMemDir dir)
Creates a MemDirAttr with the specified memory port direction.
Definition FIRRTL.cpp:378
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:251
bool firrtlTypeIsAClass(MlirType type)
Checks if this type is a class type.
Definition FIRRTL.cpp:258
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:418
MlirType firrtlTypeGetBoolean(MlirContext ctx)
Creates a property boolean type.
Definition FIRRTL.cpp:239
MlirType firrtlTypeGetDouble(MlirContext ctx)
Creates a property double type.
Definition FIRRTL.cpp:225
MlirType firrtlTypeGetPath(MlirContext ctx)
Creates a property path type.
Definition FIRRTL.cpp:245
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:233
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:217
bool firrtlTypeIsAInteger(MlirType type)
Checks if this type is a property integer type.
Definition FIRRTL.cpp:213
MlirAttribute firrtlAttrGetConvention(MlirContext ctx, FIRRTLConvention convention)
Creates an ConventionAttr with the specified value.
Definition FIRRTL.cpp:288
MlirType firrtlTypeGetClock(MlirContext ctx)
Creates a clock type.
Definition FIRRTL.cpp:65
MlirType firrtlTypeGetColoredRef(MlirType target, bool forceable, MlirAttribute layer)
Creates a ref type.
Definition FIRRTL.cpp:195
MlirAttribute firrtlAttrGetLayerConvention(MlirContext ctx, FIRRTLLayerConvention convention)
Creates a LayerConventionAttr with the specified value.
Definition FIRRTL.cpp:304
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:457
bool firrtlTypeIsAPath(MlirType type)
Checks if this type is a property path type.
Definition FIRRTL.cpp:243
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:209
MlirAttribute firrtlAttrGetPortDirs(MlirContext ctx, size_t count, const FIRRTLDirection *dirs)
Creates a DenseBoolArrayAttr with the specified port directions.
Definition FIRRTL.cpp:320
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:260
bool firrtlTypeIsAAnyRef(MlirType type)
Checks if this type is an anyref type.
Definition FIRRTL.cpp:205
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:278
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:399
bool firrtlTypeIsADouble(MlirType type)
Checks if this type is a property double type.
Definition FIRRTL.cpp:221
bool firrtlTypeIsAList(MlirType type)
Checks if this type is a property list type.
Definition FIRRTL.cpp:249
MlirAttribute firrtlAttrGetParamDecl(MlirContext ctx, MlirIdentifier name, MlirType type, MlirAttribute value)
Creates a ParamDeclAttr with the specified name, type, and value.
Definition FIRRTL.cpp:333
MlirAttribute firrtlAttrGetMemInit(MlirContext ctx, MlirIdentifier filename, bool isBinary, bool isInline)
Creates a MemoryInitAttr with the specified memory initialization information.
Definition FIRRTL.cpp:372
FIRRTLValueFlow firrtlValueFoldFlow(MlirValue value, FIRRTLValueFlow flow)
Computes the flow for a Value, value, as determined by the FIRRTL specification.
Definition FIRRTL.cpp:424
MlirAttribute firrtlAttrGetRUW(MlirContext ctx, FIRRTLRUW ruw)
Creates a RUWBehaviorAttr with the specified Read-Under-Write Behavior.
Definition FIRRTL.cpp:354
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:339
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:237
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:111
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.
Definition FIRRTLEnums.h:27
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