30 llvmStructType.def_classmethod(
32 [](py::object cls,
const std::vector<MlirType> &elements,
bool packed,
37 loc, elements.size(), elements.data(), packed);
43 "cls"_a,
"elements"_a, py::kw_only(),
"packed"_a =
false,
44 "loc"_a = py::none());
46 llvmStructType.def_classmethod(
48 [](py::object cls,
const std::string &name, MlirContext context) {
52 "cls"_a,
"name"_a, py::kw_only(),
"context"_a = py::none());
54 llvmStructType.def_classmethod(
56 [](py::object cls,
const std::string &name, MlirContext context) {
60 "cls"_a,
"name"_a,
"context"_a = py::none());
64 [](MlirType
self,
const std::vector<MlirType> &elements,
bool packed) {
66 self, elements.size(), elements.data(), packed);
68 throw py::value_error(
69 "Struct body already set to different content.");
72 "elements"_a, py::kw_only(),
"packed"_a =
false);
74 llvmStructType.def_classmethod(
76 [](py::object cls,
const std::string &name,
77 const std::vector<MlirType> &elements,
bool packed, MlirContext ctx) {
80 elements.size(), elements.
data(), packed));
82 "cls"_a,
"name"_a,
"elements"_a, py::kw_only(),
"packed"_a =
false,
83 "context"_a = py::none());
85 llvmStructType.def_property_readonly(
86 "name", [](MlirType type) -> std::optional<std::string> {
91 return StringRef(stringRef.
data, stringRef.
length).str();
94 llvmStructType.def_property_readonly(
"body", [](MlirType type) -> py::object {
107 llvmStructType.def_property_readonly(
110 llvmStructType.def_property_readonly(
120 [](py::object cls, std::optional<unsigned> addressSpace,
121 MlirContext context) {
124 context, addressSpace.has_value() ? *addressSpace : 0);
130 "cls"_a,
"address_space"_a = py::none(), py::kw_only(),
131 "context"_a = py::none())
132 .def_property_readonly(
"address_space", [](MlirType type) {
138 m.doc() =
"MLIR LLVM Dialect";
void populateDialectLLVMSubmodule(const pybind11::module &m)
PYBIND11_MODULE(_mlirDialectsLLVM, m)
RAII scope intercepting all diagnostics into a string.
std::string takeMessage()
Creates a custom subclass of mlir.ir.Type, implementing a casting constructor and type checking metho...
pure_subclass & def_classmethod(const char *name, Func &&f, const Extra &...extra)
MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeIdentifiedNewGet(MlirContext ctx, MlirStringRef name, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM identified struct type with no body and a name starting with the given prefix.
MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name)
Creates an LLVM identified struct type with no body.
MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMPointerType(MlirType type)
Returns true if the type is an LLVM dialect pointer type.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirLLVMStructTypeSetBody(MlirType structType, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Sets the body of the identified struct if it hasn't been set yet.
MLIR_CAPI_EXPORTED MlirType mlirLLVMPointerTypeGet(MlirContext ctx, unsigned addressSpace)
Creates an llvm.ptr type.
MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsLiteral(MlirType type)
Returns true if the type is a literal (unnamed) LLVM struct type.
MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMStructTypeGetIdentifier(MlirType type)
Returns the identifier of the identified struct.
MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsOpaque(MlirType type)
Returns true is the struct is explicitly opaque (will not have a body) or uninitialized (will eventua...
MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsPacked(MlirType type)
Returns true if the struct is packed.
MLIR_CAPI_EXPORTED intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type)
Returns the number of fields in the struct.
MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position)
Returns the positions-th field of the struct.
MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx, MlirStringRef name)
MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMStructType(MlirType type)
Returns true if the type is an LLVM dialect struct type.
MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type if possible.
MLIR_CAPI_EXPORTED unsigned mlirLLVMPointerTypeGetAddressSpace(MlirType pointerType)
Returns address space of llvm.ptr.
static bool mlirTypeIsNull(MlirType type)
Checks whether a type is null.
MLIR_CAPI_EXPORTED MlirContext mlirLocationGetContext(MlirLocation location)
Gets the context that a location was created with.
static MlirStringRef mlirStringRefCreate(const char *str, size_t length)
Constructs a string reference from the pointer and length.
static bool mlirLogicalResultIsSuccess(MlirLogicalResult res)
Checks if the given logical result represents a success.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
A logical result value, essentially a boolean with named states.
A pointer to a sized fragment of a string, not necessarily null-terminated.
const char * data
Pointer to the first symbol.
size_t length
Length of the fragment.