MLIR 22.0.0git
IRCore.cpp File Reference
#include "Globals.h"
#include "IRModule.h"
#include "NanobindUtils.h"
#include "mlir-c/Bindings/Python/Interop.h"
#include "mlir-c/BuiltinAttributes.h"
#include "mlir-c/Debug.h"
#include "mlir-c/Diagnostics.h"
#include "mlir-c/IR.h"
#include "mlir-c/Support.h"
#include "mlir/Bindings/Python/Nanobind.h"
#include "mlir/Bindings/Python/NanobindAdaptors.h"
#include "nanobind/nanobind.h"
#include "nanobind/typing.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include <optional>

Go to the source code of this file.

Classes

struct  PyGlobalDebugFlag
 Wrapper for the global LLVM debugging flag. More...
struct  PyAttrBuilderMap
class  PyOpResult
 Python wrapper for MlirOpResult. More...
class  PyOpResultList
 A list of operation results. More...

Macros

#define _Py_CAST(type, expr)
#define _Py_NULL   NULL
#define Py_XNewRef(obj)
#define Py_NewRef(obj)

Functions

template<class Func, typename... Args>
static nb::object classmethod (Func f, Args... args)
 Helper for creating an @classmethod.
static nb::object createCustomDialectWrapper (const std::string &dialectNamespace, nb::object dialectDescriptor)
static MlirStringRef toMlirStringRef (const std::string &s)
static MlirStringRef toMlirStringRef (std::string_view s)
static MlirStringRef toMlirStringRef (const nb::bytes &s)
static MlirBlock createBlock (const nb::sequence &pyArgTypes, const std::optional< nb::sequence > &pyArgLocs)
 Create a block, using the current location context if no locations are specified.
static void maybeInsertOperation (PyOperationRef &op, const nb::object &maybeIp)
template<typename Container>
static std::vector< nb::typed< nb::object, PyType > > getValueTypes (Container &container, PyMlirContextRef &context)
 Returns the list of types of the values held by container.
static void populateResultTypes (StringRef name, nb::list resultTypeList, const nb::object &resultSegmentSpecObj, std::vector< int32_t > &resultSegmentLengths, std::vector< PyType * > &resultTypes)
static MlirValue getUniqueResult (MlirOperation operation)
static MlirValue getOpResultOrValue (nb::handle operand)

Variables

static const char kModuleParseDocstring []
static const char kDumpDocstring []
static const char kValueReplaceAllUsesExceptDocstring []

Macro Definition Documentation

◆ _Py_CAST

#define _Py_CAST ( type,
expr )
Value:
((type)(expr))

Definition at line 2740 of file IRCore.cpp.

◆ _Py_NULL

#define _Py_NULL   NULL

Definition at line 2751 of file IRCore.cpp.

◆ Py_NewRef

#define Py_NewRef ( obj)
Value:
_Py_NewRef(_PyObject_CAST(obj))

Definition at line 2773 of file IRCore.cpp.

◆ Py_XNewRef

#define Py_XNewRef ( obj)
Value:
_Py_XNewRef(_PyObject_CAST(obj))

Definition at line 2764 of file IRCore.cpp.

Function Documentation

◆ classmethod()

template<class Func, typename... Args>
nb::object classmethod ( Func f,
Args... args )
static

Helper for creating an @classmethod.

Definition at line 59 of file IRCore.cpp.

◆ createBlock()

MlirBlock createBlock ( const nb::sequence & pyArgTypes,
const std::optional< nb::sequence > & pyArgLocs )
static

Create a block, using the current location context if no locations are specified.

Definition at line 91 of file IRCore.cpp.

References mlirBlockCreate(), and mlir::python::DefaultingPyLocation::resolve().

Referenced by mlirRewriterBaseCreateBlockBefore().

◆ createCustomDialectWrapper()

nb::object createCustomDialectWrapper ( const std::string & dialectNamespace,
nb::object dialectDescriptor )
static

◆ getOpResultOrValue()

◆ getUniqueResult()

MlirValue getUniqueResult ( MlirOperation operation)
static

◆ getValueTypes()

template<typename Container>
std::vector< nb::typed< nb::object, PyType > > getValueTypes ( Container & container,
PyMlirContextRef & context )
static

Returns the list of types of the values held by container.

Definition at line 1542 of file IRCore.cpp.

References mlir::python::PyMlirContext::getRef(), mlir::python::PyType::maybeDownCast(), mlirValueGetType(), and result.

Referenced by PyOpResultList::bindDerived().

◆ maybeInsertOperation()

◆ populateResultTypes()

void populateResultTypes ( StringRef name,
nb::list resultTypeList,
const nb::object & resultSegmentSpecObj,
std::vector< int32_t > & resultSegmentLengths,
std::vector< PyType * > & resultTypes )
static

Definition at line 1612 of file IRCore.cpp.

Referenced by mlir::python::PyOpView::buildGeneric().

◆ toMlirStringRef() [1/3]

MlirStringRef toMlirStringRef ( const nb::bytes & s)
static

Definition at line 85 of file IRCore.cpp.

References mlirStringRefCreate().

◆ toMlirStringRef() [2/3]

◆ toMlirStringRef() [3/3]

MlirStringRef toMlirStringRef ( std::string_view s)
static

Definition at line 81 of file IRCore.cpp.

References mlirStringRefCreate().

Variable Documentation

◆ kDumpDocstring

const char kDumpDocstring[]
static
Initial value:
=
"Dumps a debug representation of the object to stderr."

Definition at line 44 of file IRCore.cpp.

◆ kModuleParseDocstring

const char kModuleParseDocstring[]
static
Initial value:
=
R"(Parses a module's assembly format from a string.
Returns a new MlirModule or raises an MLIRError if the parsing fails.
See also: https://mlir.llvm.org/docs/LangRef/
)"

Definition at line 36 of file IRCore.cpp.

◆ kValueReplaceAllUsesExceptDocstring

const char kValueReplaceAllUsesExceptDocstring[]
static
Initial value:
=
R"(Replace all uses of this value with the `with` value, except for those
in `exceptions`. `exceptions` can be either a single operation or a list of
operations.
)"

Definition at line 47 of file IRCore.cpp.