15#include "mlir/CAPI/Registration.h"
36 return isa<SequenceType>(
unwrap(type));
40 MlirType
const *elementTypes) {
41 SmallVector<Type> types;
43 types.emplace_back(
unwrap(elementTypes[i]));
44 return wrap(SequenceType::get(
unwrap(ctxt), types));
48 return cast<SequenceType>(
unwrap(type)).getElementTypes().size();
52 return wrap(cast<SequenceType>(
unwrap(type)).getElementTypes()[i]);
59 return isa<RandomizedSequenceType>(
unwrap(type));
63 return wrap(RandomizedSequenceType::get(
unwrap(ctxt)));
82 return wrap(SetType::get(ty.getContext(), ty));
86 return wrap(cast<SetType>(
unwrap(type)).getElementType());
96 return wrap(BagType::get(ty.getContext(), ty));
100 return wrap(cast<BagType>(
unwrap(type)).getElementType());
109 MlirAttribute
const *entryNames,
110 MlirType
const *entryTypes) {
111 SmallVector<DictEntry> entries;
112 for (
unsigned i = 0; i < numEntries; ++i) {
114 entry.
name = cast<StringAttr>(
unwrap(entryNames[i]));
116 entries.emplace_back(entry);
118 return wrap(DictType::get(
unwrap(ctxt), entries));
132 return wrap(cast<ArrayType>(
unwrap(type)).getElementType());
139 return isa<ImmediateType>(
unwrap(type));
143 return wrap(ImmediateType::get(
unwrap(ctx), width));
147 return cast<ImmediateType>(
unwrap(type)).getWidth();
156 return wrap(MemoryType::get(
unwrap(ctxt), addressWidth));
160 return cast<MemoryType>(
unwrap(type)).getAddressWidth();
167 return isa<MemoryBlockType>(
unwrap(type));
171 return wrap(MemoryBlockType::get(
unwrap(ctxt), addressWidth));
175 return cast<MemoryBlockType>(
unwrap(type)).getAddressWidth();
186 return isa<DefaultContextAttr>(
unwrap(attr));
197 return isa<LabelVisibilityAttr>(
unwrap(attr));
201 auto convert = [](LabelVisibility visibility) {
202 switch (visibility) {
203 case LabelVisibility::local:
205 case LabelVisibility::global:
207 case LabelVisibility::external:
211 return convert(cast<LabelVisibilityAttr>(
unwrap(attr)).getValue());
217 switch (visibility) {
219 return LabelVisibility::local;
221 return LabelVisibility::global;
223 return LabelVisibility::external;
226 return wrap(LabelVisibilityAttr::get(
unwrap(ctxt), convert(visibility)));
233 return isa<ImmediateAttr>(
unwrap(attr));
238 return wrap(rtg::ImmediateAttr::get(
unwrap(ctx), APInt(width, value)));
242 return cast<ImmediateAttr>(
unwrap(attr)).getValue().getBitWidth();
246 return cast<ImmediateAttr>(
unwrap(attr)).getValue().getZExtValue();
253 return isa<AnyContextAttr>(
unwrap(attr));
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
MlirType uint64_t numElements
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(CHIRRTL, chirrtl, circt::chirrtl::CHIRRTLDialect) MlirType chirrtlTypeGetCMemory(MlirContext ctx
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
bool rtgTypeIsABag(MlirType type)
If the type is an RTG bag.
MlirAttribute rtgAnyContextAttrGet(MlirContext ctxt, MlirType type)
Creates an RTG any context attribute in the context.
bool rtgAttrIsAAnyContextAttr(MlirAttribute attr)
If the attribute is an RTG any context attribute.
MlirType rtgSequenceTypeGetElement(MlirType type, unsigned i)
The type of of the substitution element at the given index.
MlirType rtgArrayTypeGet(MlirType elementType)
Creates an RTG array type in the context.
bool rtgTypeIsARandomizedSequence(MlirType type)
If the type is an RTG randomized sequence.
RTGLabelVisibility rtgLabelVisibilityAttrGetValue(MlirAttribute attr)
Get the RTG label visibility from the attribute.
MlirType rtgSetTypeGet(MlirType elementType)
Creates an RTG set type in the context.
MlirType rtgArrayTypeGetElementType(MlirType type)
Returns the element type of the RTG array.
MlirAttribute rtgLabelVisibilityAttrGet(MlirContext ctxt, RTGLabelVisibility visibility)
Creates an RTG label visibility attribute in the context.
bool rtgAttrIsALabelVisibilityAttr(MlirAttribute attr)
If the attribute is an RTG label visibility.
uint32_t rtgMemoryBlockTypeGetAddressWidth(MlirType type)
Returns the address with of an RTG memory block type.
MlirType rtgImmediateTypeGet(MlirContext ctx, uint32_t width)
Creates an RTG immediate type in the context.
bool rtgAttrIsAImmediate(MlirAttribute attr)
Checks if the attribute is an RTG immediate attribute.
MlirType rtgSequenceTypeGet(MlirContext ctxt, intptr_t numElements, MlirType const *elementTypes)
Creates an RTG sequence type in the context.
uint32_t rtgImmediateAttrGetWidth(MlirAttribute attr)
Returns the width of the RTG immediate attribute.
bool rtgTypeIsAArray(MlirType type)
If the type is an RTG array.
MlirType rtgMemoryTypeGet(MlirContext ctxt, uint32_t addressWidth)
Creates an RTG memory type in the context.
bool rtgTypeIsASet(MlirType type)
If the type is an RTG set.
bool rtgTypeIsAMemory(MlirType type)
If the type is an RTG memory.
bool rtgTypeIsADict(MlirType type)
If the type is an RTG dict.
unsigned rtgSequenceTypeGetNumElements(MlirType type)
The number of substitution elements of the RTG sequence.
MlirType rtgRandomizedSequenceTypeGet(MlirContext ctxt)
Creates an RTG randomized sequence type in the context.
bool rtgTypeIsALabel(MlirType type)
If the type is an RTG label.
MlirType rtgSetTypeGetElementType(MlirType type)
Return the element type of the RTG set.
bool rtgTypeIsAMemoryBlock(MlirType type)
If the type is an RTG memory block.
MlirAttribute rtgImmediateAttrGet(MlirContext ctx, uint32_t width, uint64_t value)
Creates an RTG immediate attribute in the context with the given width and value.
uint64_t rtgImmediateAttrGetValue(MlirAttribute attr)
Returns the value of the RTG immediate attribute.
MlirType rtgDictTypeGet(MlirContext ctxt, intptr_t numEntries, MlirAttribute const *entryNames, MlirType const *entryTypes)
Creates an RTG dict type in the context.
uint32_t rtgImmediateTypeGetWidth(MlirType type)
Returns the width of the RTG immediate type.
bool rtgTypeIsASequence(MlirType type)
If the type is an RTG sequence.
MlirType rtgBagTypeGet(MlirType elementType)
Creates an RTG bag type in the context.
MlirType rtgLabelTypeGet(MlirContext ctxt)
Creates an RTG mode type in the context.
bool rtgTypeIsAImmediate(MlirType type)
If the type is an RTG immediate.
uint32_t rtgMemoryTypeGetAddressWidth(MlirType type)
Returns the address with of an RTG memory type.
MlirType rtgMemoryBlockTypeGet(MlirContext ctxt, uint32_t addressWidth)
Creates an RTG memory block type in the context.
MlirAttribute rtgDefaultContextAttrGet(MlirContext ctxt, MlirType type)
Creates an RTG default context attribute in the context.
MlirType rtgBagTypeGetElementType(MlirType type)
Return the element type of the RTG bag.
bool rtgAttrIsADefaultContextAttr(MlirAttribute attr)
If the attribute is an RTG default context.
@ RTG_LABEL_VISIBILITY_EXTERNAL
@ RTG_LABEL_VISIBILITY_GLOBAL
@ RTG_LABEL_VISIBILITY_LOCAL
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Defines an entry in an !rtg.dict.