MLIR 22.0.0git
mlir::python::PyInsertionPoint Class Reference

An insertion point maintains a pointer to a Block and a reference operation. More...

#include "Bindings/Python/IRModule.h"

Public Member Functions

 PyInsertionPoint (const PyBlock &block)
 Creates an insertion point positioned after the last operation in the block, but still inside the block.
 PyInsertionPoint (PyOperationBase &beforeOperationBase)
 Creates an insertion point positioned before a reference operation.
 PyInsertionPoint (PyOperationRef beforeOperationRef)
 Creates an insertion point positioned before a reference operation.
void insert (PyOperationBase &operationBase)
 Inserts an operation.
void contextExit (const nanobind::object &excType, const nanobind::object &excVal, const nanobind::object &excTb)
PyBlockgetBlock ()
std::optional< PyOperationRef > & getRefOperation ()

Static Public Member Functions

static PyInsertionPoint atBlockBegin (PyBlock &block)
 Shortcut to create an insertion point at the beginning of the block.
static PyInsertionPoint atBlockTerminator (PyBlock &block)
 Shortcut to create an insertion point before the block terminator.
static PyInsertionPoint after (PyOperationBase &op)
 Shortcut to create an insertion point to the node after the specified operation.
static nanobind::object contextEnter (nanobind::object insertionPoint)
 Enter and exit the context manager.

Detailed Description

An insertion point maintains a pointer to a Block and a reference operation.

Calls to insert() will insert a new operation before the reference operation. If the reference operation is null, then appends to the end of the block.

Definition at line 837 of file IRModule.h.

Constructor & Destructor Documentation

◆ PyInsertionPoint() [1/3]

PyInsertionPoint::PyInsertionPoint ( const PyBlock & block)

Creates an insertion point positioned after the last operation in the block, but still inside the block.

Definition at line 1939 of file IRCore.cpp.

Referenced by after(), atBlockBegin(), and atBlockTerminator().

◆ PyInsertionPoint() [2/3]

PyInsertionPoint::PyInsertionPoint ( PyOperationBase & beforeOperationBase)

Creates an insertion point positioned before a reference operation.

Definition at line 1941 of file IRCore.cpp.

References getBlock().

◆ PyInsertionPoint() [3/3]

PyInsertionPoint::PyInsertionPoint ( PyOperationRef beforeOperationRef)

Creates an insertion point positioned before a reference operation.

Definition at line 1945 of file IRCore.cpp.

References getBlock().

Member Function Documentation

◆ after()

PyInsertionPoint PyInsertionPoint::after ( PyOperationBase & op)
static

Shortcut to create an insertion point to the node after the specified operation.

Definition at line 1996 of file IRCore.cpp.

References mlir::python::PyOperation::forOperation(), mlir::python::PyOperation::getBlock(), mlir::python::PyOperationBase::getOperation(), mlirOperationGetNextInBlock(), and PyInsertionPoint().

◆ atBlockBegin()

PyInsertionPoint PyInsertionPoint::atBlockBegin ( PyBlock & block)
static

Shortcut to create an insertion point at the beginning of the block.

Definition at line 1974 of file IRCore.cpp.

References mlir::python::PyOperation::forOperation(), mlirBlockGetFirstOperation(), and PyInsertionPoint().

◆ atBlockTerminator()

PyInsertionPoint PyInsertionPoint::atBlockTerminator ( PyBlock & block)
static

Shortcut to create an insertion point before the block terminator.

Definition at line 1987 of file IRCore.cpp.

References mlir::python::PyOperation::forOperation(), mlirBlockGetTerminator(), and PyInsertionPoint().

◆ contextEnter()

nb::object PyInsertionPoint::contextEnter ( nanobind::object insertionPoint)
static

Enter and exit the context manager.

Definition at line 2009 of file IRCore.cpp.

References mlir::python::PyThreadContextEntry::pushInsertionPoint().

◆ contextExit()

void PyInsertionPoint::contextExit ( const nanobind::object & excType,
const nanobind::object & excVal,
const nanobind::object & excTb )

◆ getBlock()

PyBlock & mlir::python::PyInsertionPoint::getBlock ( )
inline

Definition at line 864 of file IRModule.h.

Referenced by PyInsertionPoint(), and PyInsertionPoint().

◆ getRefOperation()

std::optional< PyOperationRef > & mlir::python::PyInsertionPoint::getRefOperation ( )
inline

Definition at line 865 of file IRModule.h.

◆ insert()


The documentation for this class was generated from the following files: