13#include "mlir/Bindings/Python/NanobindAdaptors.h"
15#include <nanobind/nanobind.h>
20using namespace mlir::python::nanobind_adaptors;
24 m.doc() =
"RTG dialect Python native extension";
36 [](nb::object cls, std::vector<MlirType> &elementTypes,
39 elementTypes.data()));
41 nb::arg(
"self"), nb::arg(
"elementTypes") = std::vector<MlirType>(),
42 nb::arg(
"ctxt") =
nullptr)
43 .def_property_readonly(
46 .def(
"get_element", [](MlirType self,
unsigned i) {
53 [](nb::object cls, MlirContext ctxt) {
56 nb::arg(
"self"), nb::arg(
"ctxt") =
nullptr);
67 nb::arg(
"self"), nb::arg(
"element_type"))
68 .def_property_readonly(
"element_type", [](MlirType self) {
78 nb::arg(
"self"), nb::arg(
"element_type"))
79 .def_property_readonly(
"element_type", [](MlirType self) {
87 const std::vector<std::pair<MlirAttribute, MlirType>> &entries,
89 std::vector<MlirAttribute> names;
90 std::vector<MlirType> types;
91 for (
auto entry : entries) {
92 names.push_back(entry.first);
93 types.push_back(entry.second);
100 std::vector<std::pair<MlirAttribute, MlirType>>(),
101 nb::arg(
"ctxt") =
nullptr);
106 [](nb::object cls, MlirType
elementType, MlirContext ctxt) {
109 nb::arg(
"self"), nb::arg(
"element_type"), nb::arg(
"ctxt") =
nullptr)
110 .def_property_readonly(
"element_type", [](MlirType self) {
120 [](nb::object cls, MlirContext ctxt) {
123 nb::arg(
"self"), nb::arg(
"ctxt") =
nullptr);
128 [](nb::object cls, uint32_t width, MlirContext ctx) {
131 nb::arg(
"self"), nb::arg(
"width"), nb::arg(
"ctx") =
nullptr)
132 .def_property_readonly(
"width", [](MlirType self) {
143 [](nb::object cls, MlirType type, MlirContext ctxt) {
146 nb::arg(
"self"), nb::arg(
"type"), nb::arg(
"ctxt") =
nullptr);
151 nb::enum_<RTGLabelVisibility>(m,
"LabelVisibility")
157 mlir_attribute_subclass(m,
"LabelVisibilityAttr",
164 nb::arg(
"self"), nb::arg(
"visibility"), nb::arg(
"ctxt") =
nullptr)
165 .def_property_readonly(
"value", [](MlirAttribute self) {
172 [](nb::object cls, uint32_t width, uint64_t value, MlirContext ctx) {
175 nb::arg(
"self"), nb::arg(
"width"), nb::arg(
"value"),
176 nb::arg(
"ctx") =
nullptr)
177 .def_property_readonly(
180 .def_property_readonly(
"value", [](MlirAttribute self) {
MLIR_CAPI_EXPORTED MlirType rtgLabelTypeGet(MlirContext ctxt)
Creates an RTG mode type in the context.
MLIR_CAPI_EXPORTED RTGLabelVisibility rtgLabelVisibilityAttrGetValue(MlirAttribute attr)
Get the RTG label visibility from the attribute.
MLIR_CAPI_EXPORTED uint32_t rtgImmediateAttrGetWidth(MlirAttribute attr)
Returns the width of the RTG immediate attribute.
@ RTG_LABEL_VISIBILITY_EXTERNAL
@ RTG_LABEL_VISIBILITY_GLOBAL
@ RTG_LABEL_VISIBILITY_LOCAL
MLIR_CAPI_EXPORTED MlirType rtgSequenceTypeGetElement(MlirType type, unsigned i)
The type of of the substitution element at the given index.
MLIR_CAPI_EXPORTED MlirAttribute rtgDefaultContextAttrGet(MlirContext ctxt, MlirType type)
Creates an RTG default context attribute in the context.
MLIR_CAPI_EXPORTED MlirType rtgImmediateTypeGet(MlirContext ctx, uint32_t width)
Creates an RTG immediate type in the context.
MLIR_CAPI_EXPORTED bool rtgTypeIsAArray(MlirType type)
If the type is an RTG array.
MLIR_CAPI_EXPORTED bool rtgAttrIsALabelVisibilityAttr(MlirAttribute attr)
If the attribute is an RTG label visibility.
MLIR_CAPI_EXPORTED MlirAttribute rtgLabelVisibilityAttrGet(MlirContext ctxt, RTGLabelVisibility visibility)
Creates an RTG label visibility attribute in the context.
MLIR_CAPI_EXPORTED MlirType rtgArrayTypeGetElementType(MlirType type)
Returns the element type of the RTG array.
MLIR_CAPI_EXPORTED bool rtgTypeIsABag(MlirType type)
If the type is an RTG bag.
MLIR_CAPI_EXPORTED MlirType rtgSequenceTypeGet(MlirContext ctxt, intptr_t numElements, MlirType const *elementTypes)
Creates an RTG sequence type in the context.
MLIR_CAPI_EXPORTED MlirAttribute rtgImmediateAttrGet(MlirContext ctx, uint32_t width, uint64_t value)
Creates an RTG immediate attribute in the context with the given width and value.
MLIR_CAPI_EXPORTED unsigned rtgSequenceTypeGetNumElements(MlirType type)
The number of substitution elements of the RTG sequence.
MLIR_CAPI_EXPORTED MlirType rtgSetTypeGet(MlirType elementType)
Creates an RTG set type in the context.
MLIR_CAPI_EXPORTED bool rtgTypeIsASet(MlirType type)
If the type is an RTG set.
MLIR_CAPI_EXPORTED MlirType rtgRandomizedSequenceTypeGet(MlirContext ctxt)
Creates an RTG randomized sequence type in the context.
MLIR_CAPI_EXPORTED uint64_t rtgImmediateAttrGetValue(MlirAttribute attr)
Returns the value of the RTG immediate attribute.
MLIR_CAPI_EXPORTED bool rtgAttrIsAImmediate(MlirAttribute attr)
Checks if the attribute is an RTG immediate attribute.
MLIR_CAPI_EXPORTED bool rtgTypeIsARandomizedSequence(MlirType type)
If the type is an RTG randomized sequence.
MLIR_CAPI_EXPORTED bool rtgTypeIsADict(MlirType type)
If the type is an RTG dict.
MLIR_CAPI_EXPORTED bool rtgTypeIsAImmediate(MlirType type)
If the type is an RTG immediate.
MLIR_CAPI_EXPORTED MlirType rtgDictTypeGet(MlirContext ctxt, intptr_t numEntries, MlirAttribute const *entryNames, MlirType const *entryTypes)
Creates an RTG dict type in the context.
MLIR_CAPI_EXPORTED MlirType rtgBagTypeGet(MlirType elementType)
Creates an RTG bag type in the context.
MLIR_CAPI_EXPORTED MlirType rtgArrayTypeGet(MlirType elementType)
Creates an RTG array type in the context.
MLIR_CAPI_EXPORTED MlirType rtgBagTypeGetElementType(MlirType type)
Return the element type of the RTG bag.
MLIR_CAPI_EXPORTED bool rtgTypeIsASequence(MlirType type)
If the type is an RTG sequence.
MLIR_CAPI_EXPORTED bool rtgTypeIsALabel(MlirType type)
If the type is an RTG label.
MLIR_CAPI_EXPORTED uint32_t rtgImmediateTypeGetWidth(MlirType type)
Returns the width of the RTG immediate type.
MLIR_CAPI_EXPORTED MlirType rtgSetTypeGetElementType(MlirType type)
Return the element type of the RTG set.
MLIR_CAPI_EXPORTED bool rtgAttrIsADefaultContextAttr(MlirAttribute attr)
If the attribute is an RTG default context.
void populateDialectRTGSubmodule(nanobind::module_ &m)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.