16#include "mlir/CAPI/Pass.h"
17#include "mlir/CAPI/Registration.h"
38 return isa<SequenceType>(
unwrap(type));
42 MlirType
const *elementTypes) {
43 SmallVector<Type> types;
45 types.emplace_back(
unwrap(elementTypes[i]));
46 return wrap(SequenceType::get(
unwrap(ctxt), types));
50 return cast<SequenceType>(
unwrap(type)).getElementTypes().size();
54 return wrap(cast<SequenceType>(
unwrap(type)).getElementTypes()[i]);
61 return isa<RandomizedSequenceType>(
unwrap(type));
65 return wrap(RandomizedSequenceType::get(
unwrap(ctxt)));
84 return wrap(SetType::get(ty.getContext(), ty));
88 return wrap(cast<SetType>(
unwrap(type)).getElementType());
98 return wrap(BagType::get(ty.getContext(), ty));
102 return wrap(cast<BagType>(
unwrap(type)).getElementType());
111 MlirAttribute
const *entryNames,
112 MlirType
const *entryTypes) {
113 SmallVector<DictEntry> entries;
114 for (
unsigned i = 0; i < numEntries; ++i) {
116 entry.
name = cast<StringAttr>(
unwrap(entryNames[i]));
118 entries.emplace_back(entry);
120 return wrap(DictType::get(
unwrap(ctxt), entries));
134 return wrap(cast<ArrayType>(
unwrap(type)).getElementType());
147 return wrap(cast<MapType>(
unwrap(type)).getKeyType());
151 return wrap(cast<MapType>(
unwrap(type)).getValueType());
158 MlirType
const *fieldTypes) {
159 SmallVector<Type> types;
160 for (
unsigned i = 0; i < numFields; ++i)
161 types.emplace_back(
unwrap(fieldTypes[i]));
162 return wrap(rtg::TupleType::get(
unwrap(ctxt), types));
166 return isa<rtg::TupleType>(
unwrap(type));
170 return cast<rtg::TupleType>(
unwrap(type)).getFieldTypes().size();
174 return wrap(cast<rtg::TupleType>(
unwrap(type)).getFieldTypes()[idx]);
183 return wrap(MemoryType::get(
unwrap(ctxt), addressWidth));
187 return cast<MemoryType>(
unwrap(type)).getAddressWidth();
194 return isa<MemoryBlockType>(
unwrap(type));
198 return wrap(MemoryBlockType::get(
unwrap(ctxt), addressWidth));
202 return cast<MemoryBlockType>(
unwrap(type)).getAddressWidth();
222 return isa<DefaultContextAttr>(
unwrap(attr));
233 return isa<LabelVisibilityAttr>(
unwrap(attr));
237 auto convert = [](LabelVisibility visibility) {
238 switch (visibility) {
239 case LabelVisibility::local:
241 case LabelVisibility::global:
243 case LabelVisibility::external:
247 return convert(cast<LabelVisibilityAttr>(
unwrap(attr)).getValue());
253 switch (visibility) {
255 return LabelVisibility::local;
257 return LabelVisibility::global;
259 return LabelVisibility::external;
269 return isa<AnyContextAttr>(
unwrap(attr));
280 return isa<VirtualRegisterConfigAttr>(
unwrap(attr));
285 MlirAttribute
const *allowedRegs) {
286 SmallVector<rtg::RegisterAttrInterface> regs;
287 for (intptr_t i = 0; i < numRegs; ++i)
288 regs.push_back(cast<rtg::RegisterAttrInterface>(
unwrap(allowedRegs[i])));
289 return wrap(VirtualRegisterConfigAttr::get(
unwrap(ctxt), regs));
293 return cast<VirtualRegisterConfigAttr>(
unwrap(attr)).getAllowedRegs().size();
299 cast<VirtualRegisterConfigAttr>(
unwrap(attr)).getAllowedRegs();
300 return wrap(allowedRegs[index]);
307 return isa<LabelAttr>(
unwrap(attr));
315 return wrap(cast<LabelAttr>(
unwrap(attr)).getName());
322 return isa<rtg::MapAttr>(
unwrap(attr));
326 intptr_t numEntries, MlirAttribute
const *keys,
327 MlirAttribute
const *values) {
328 DenseMap<TypedAttr, TypedAttr> entries;
329 for (
unsigned i = 0; i < numEntries; ++i) {
331 {cast<TypedAttr>(
unwrap(keys[i])), cast<TypedAttr>(
unwrap(values[i]))});
333 return wrap(rtg::MapAttr::get(cast<rtg::MapType>(
unwrap(mapType)), &entries));
337 auto mapAttr = cast<rtg::MapAttr>(
unwrap(attr));
338 auto keyAttr = cast<TypedAttr>(
unwrap(key));
340 auto it = mapAttr.getEntries()->find(keyAttr);
341 if (it == mapAttr.getEntries()->end())
342 return wrap(Attribute());
344 return wrap(it->second);
351#include "circt/Dialect/RTG/Transforms/RTGPasses.capi.cpp.inc"
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 LogicalResult convert(arc::ExecuteOp op, arc::ExecuteOp::Adaptor adaptor, ConversionPatternRewriter &rewriter, const TypeConverter &converter)
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.
intptr_t rtgTypeGetNumFields(MlirType type)
Returns the number of fields in the RTG tuple.
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 rtgSequenceTypeGet(MlirContext ctxt, intptr_t numElements, MlirType const *elementTypes)
Creates an RTG sequence type in the context.
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.
MlirAttribute rtgVirtualRegisterConfigAttrGet(MlirContext ctxt, intptr_t numRegs, MlirAttribute const *allowedRegs)
Creates an RTG virtual register config attribute in the context.
bool rtgAttrIsAVirtualRegisterConfig(MlirAttribute attr)
Checks if the attribute is an RTG virtual register config attribute.
bool rtgTypeIsADict(MlirType type)
If the type is an RTG dict.
unsigned rtgSequenceTypeGetNumElements(MlirType type)
The number of substitution elements of the RTG sequence.
bool rtgAttrIsAMap(MlirAttribute attr)
Checks if the attribute is an RTG map attribute.
MlirType rtgRandomizedSequenceTypeGet(MlirContext ctxt)
Creates an RTG randomized sequence type in the context.
MlirType rtgStringTypeGet(MlirContext ctxt)
Creates an RTG string type in the context.
bool rtgTypeIsALabel(MlirType type)
If the type is an RTG label.
void registerRTGPipelines()
MlirType rtgMapTypeGet(MlirType keyType, MlirType valueType)
Creates an RTG map type in the context.
MlirType rtgSetTypeGetElementType(MlirType type)
Return the element type of the RTG set.
bool rtgTypeIsAMemoryBlock(MlirType type)
If the type is an RTG memory block.
bool rtgTypeIsAString(MlirType type)
If the type is an RTG string.
bool rtgAttrIsALabel(MlirAttribute attr)
Checks if the attribute is an RTG label attribute.
MlirStringRef rtgLabelAttrGetName(MlirAttribute attr)
Returns the name of the RTG label attribute.
MlirType rtgMapTypeGetKeyType(MlirType type)
Return the key type of the RTG map.
MlirType rtgDictTypeGet(MlirContext ctxt, intptr_t numEntries, MlirAttribute const *entryNames, MlirType const *entryTypes)
Creates an RTG dict type in the context.
bool rtgTypeIsASequence(MlirType type)
If the type is an RTG sequence.
bool rtgTypeIsAMap(MlirType type)
If the type is an RTG map.
MlirType rtgTupleTypeGetFieldType(MlirType type, intptr_t idx)
Returns a field type of the RTG tuple.
MlirType rtgBagTypeGet(MlirType elementType)
Creates an RTG bag type in the context.
MlirAttribute rtgVirtualRegisterConfigAttrGetRegister(MlirAttribute attr, intptr_t index)
Returns the allowed register at the given index in the RTG virtual register config attribute.
MlirType rtgLabelTypeGet(MlirContext ctxt)
Creates an RTG mode type in the context.
MlirAttribute rtgMapAttrLookup(MlirAttribute attr, MlirAttribute key)
Looks up the value associated with the given key in the RTG map attribute.
MlirType rtgTupleTypeGet(MlirContext ctxt, intptr_t numFields, MlirType const *fieldTypes)
Creates an RTG tuple type in the context.
MlirType rtgMapTypeGetValueType(MlirType type)
Return the value type of the RTG map.
uint32_t rtgMemoryTypeGetAddressWidth(MlirType type)
Returns the address with of an RTG memory type.
MlirAttribute rtgMapAttrGet(MlirContext ctx, MlirType mapType, intptr_t numEntries, MlirAttribute const *keys, MlirAttribute const *values)
Creates an RTG map attribute in the context with the given entries.
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.
bool rtgTypeIsATuple(MlirType type)
If the type is an RTG tuple.
MlirType rtgBagTypeGetElementType(MlirType type)
Return the element type of the RTG bag.
intptr_t rtgVirtualRegisterConfigAttrGetNumRegisters(MlirAttribute attr)
Returns the number of allowed registers in the RTG virtual register config attribute.
bool rtgAttrIsADefaultContextAttr(MlirAttribute attr)
If the attribute is an RTG default context.
MlirAttribute rtgLabelAttrGet(MlirContext ctx, MlirStringRef name)
Creates an RTG label attribute in the context with the given name.
@ RTG_LABEL_VISIBILITY_EXTERNAL
@ RTG_LABEL_VISIBILITY_GLOBAL
@ RTG_LABEL_VISIBILITY_LOCAL
void registerPipelines()
Registers all pipelines for the rtg dialect.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Defines an entry in an !rtg.dict.