MLIR  19.0.0git
Classes | Functions | Variables
IRCore.cpp File Reference
#include "IRModule.h"
#include "Globals.h"
#include "PybindUtils.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/PybindAdaptors.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include <optional>
#include <utility>

Go to the source code of this file.

Classes

struct  PyGlobalDebugFlag
 Wrapper for the global LLVM debugging flag. More...
 
struct  PyAttrBuilderMap
 

Functions

template<class Func , typename... Args>
py::object classmethod (Func f, Args... args)
 Helper for creating an @classmethod. More...
 
static py::object createCustomDialectWrapper (const std::string &dialectNamespace, py::object dialectDescriptor)
 
static MlirStringRef toMlirStringRef (const std::string &s)
 
static MlirBlock createBlock (const py::sequence &pyArgTypes, const std::optional< py::sequence > &pyArgLocs)
 Create a block, using the current location context if no locations are specified. More...
 
static void maybeInsertOperation (PyOperationRef &op, const py::object &maybeIp)
 
static void populateResultTypes (StringRef name, py::list resultTypeList, const py::object &resultSegmentSpecObj, std::vector< int32_t > &resultSegmentLengths, std::vector< PyType * > &resultTypes)
 

Variables

static const char kContextParseTypeDocstring []
 
static const char kContextGetCallSiteLocationDocstring []
 
static const char kContextGetFileLocationDocstring []
 
static const char kContextGetFusedLocationDocstring []
 
static const char kContextGetNameLocationDocString []
 
static const char kModuleParseDocstring []
 
static const char kOperationCreateDocstring []
 
static const char kOperationPrintDocstring []
 
static const char kOperationPrintStateDocstring []
 
static const char kOperationGetAsmDocstring []
 
static const char kOperationPrintBytecodeDocstring []
 
static const char kOperationStrDunderDocstring []
 
static const char kDumpDocstring []
 
static const char kAppendBlockDocstring []
 
static const char kValueDunderStrDocstring []
 
static const char kGetNameAsOperand []
 
static const char kValueReplaceAllUsesWithDocstring []
 

Function Documentation

◆ classmethod()

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

Helper for creating an @classmethod.

Definition at line 186 of file IRCore.cpp.

◆ createBlock()

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

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

Definition at line 210 of file IRCore.cpp.

References mlirBlockCreate().

Referenced by mlir::OneToNPatternRewriter::applySignatureConversion().

◆ createCustomDialectWrapper()

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

Definition at line 192 of file IRCore.cpp.

References mlir::get().

◆ maybeInsertOperation()

static void maybeInsertOperation ( PyOperationRef op,
const py::object &  maybeIp 
)
static

Definition at line 1334 of file IRCore.cpp.

Referenced by mlir::python::PyOperation::clone().

◆ populateResultTypes()

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

Definition at line 1511 of file IRCore.cpp.

References mlir::detail::enumerate().

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

◆ toMlirStringRef()

static MlirStringRef toMlirStringRef ( const std::string &  s)
static

Variable Documentation

◆ kAppendBlockDocstring

const char kAppendBlockDocstring[]
static
Initial value:
=
R"(Appends a new block, with argument types as positional args.
Returns:
The created block.
)"

Definition at line 156 of file IRCore.cpp.

◆ kContextGetCallSiteLocationDocstring

const char kContextGetCallSiteLocationDocstring[]
static
Initial value:
=
R"(Gets a Location representing a caller and callsite)"

Definition at line 48 of file IRCore.cpp.

◆ kContextGetFileLocationDocstring

const char kContextGetFileLocationDocstring[]
static
Initial value:
=
R"(Gets a Location representing a file, line and column)"

Definition at line 51 of file IRCore.cpp.

◆ kContextGetFusedLocationDocstring

const char kContextGetFusedLocationDocstring[]
static
Initial value:
=
R"(Gets a Location representing a fused location with optional metadata)"

Definition at line 54 of file IRCore.cpp.

◆ kContextGetNameLocationDocString

const char kContextGetNameLocationDocString[]
static
Initial value:
=
R"(Gets a Location representing a named location with optional child location)"

Definition at line 57 of file IRCore.cpp.

◆ kContextParseTypeDocstring

const char kContextParseTypeDocstring[]
static
Initial value:
=
R"(Parses the assembly form of a type.
Returns a Type object or raises an MLIRError if the type cannot be parsed.
See also: https://mlir.llvm.org/docs/LangRef/#type-system
)"

Definition at line 40 of file IRCore.cpp.

◆ kDumpDocstring

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

Definition at line 153 of file IRCore.cpp.

◆ kGetNameAsOperand

const char kGetNameAsOperand[]
static
Initial value:
=
R"(Returns the string form of value as an operand (i.e., the ValueID).
)"

Definition at line 171 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 60 of file IRCore.cpp.

◆ kOperationCreateDocstring

const char kOperationCreateDocstring[]
static
Initial value:
=
R"(Creates a new operation.
Args:
name: Operation name (e.g. "dialect.operation").
results: Sequence of Type representing op result types.
attributes: Dict of str:Attribute.
successors: List of Block for the operation's successors.
regions: Number of regions to create.
location: A Location object (defaults to resolve from context manager).
ip: An InsertionPoint (defaults to resolve from context manager or set to
False to disable insertion, even with an insertion point set in the
context manager).
infer_type: Whether to infer result types.
Returns:
A new "detached" Operation object. Detached operations can be added
to blocks, which causes them to become "attached."
)"

Definition at line 68 of file IRCore.cpp.

◆ kOperationGetAsmDocstring

const char kOperationGetAsmDocstring[]
static
Initial value:
=
R"(Gets the assembly form of the operation with all options available.
Args:
binary: Whether to return a bytes (True) or str (False) object. Defaults to
False.
... others ...: See the print() method for common keyword arguments for
configuring the printout.
Returns:
Either a bytes or str object, depending on the setting of the 'binary'
argument.
)"

Definition at line 122 of file IRCore.cpp.

◆ kOperationPrintBytecodeDocstring

const char kOperationPrintBytecodeDocstring[]
static
Initial value:
=
R"(Write the bytecode form of the operation to a file like object.
Args:
file: The file like object to write to.
desired_version: The version of bytecode to emit.
Returns:
The bytecode writer status.
)"

Definition at line 135 of file IRCore.cpp.

◆ kOperationPrintDocstring

const char kOperationPrintDocstring[]
static
Initial value:
=
R"(Prints the assembly form of the operation to a file like object.
Args:
file: The file like object to write to. Defaults to sys.stdout.
binary: Whether to write bytes (True) or str (False). Defaults to False.
large_elements_limit: Whether to elide elements attributes above this
number of elements. Defaults to None (no limit).
enable_debug_info: Whether to print debug/location information. Defaults
to False.
pretty_debug_info: Whether to format debug information for easier reading
by a human (warning: the result is unparseable).
print_generic_op_form: Whether to print the generic assembly forms of all
ops. Defaults to False.
use_local_Scope: Whether to print in a way that is more optimized for
multi-threaded access but may not be consistent with how the overall
module prints.
assume_verified: By default, if not printing generic form, the verifier
will be run and if it fails, generic form will be printed with a comment
about failed verification. While a reasonable default for interactive use,
for systematic use, it is often better for the caller to verify explicitly
and report failures in a more robust fashion. Set this to True if doing this
in order to avoid running a redundant verification. If the IR is actually
invalid, behavior is undefined.
)"

Definition at line 87 of file IRCore.cpp.

◆ kOperationPrintStateDocstring

const char kOperationPrintStateDocstring[]
static
Initial value:
=
R"(Prints the assembly form of the operation to a file like object.
Args:
file: The file like object to write to. Defaults to sys.stdout.
binary: Whether to write bytes (True) or str (False). Defaults to False.
state: AsmState capturing the operation numbering and flags.
)"

Definition at line 113 of file IRCore.cpp.

◆ kOperationStrDunderDocstring

const char kOperationStrDunderDocstring[]
static
Initial value:
=
R"(Gets the assembly form of the operation with default options.
If more advanced control over the assembly formatting or I/O options is needed,
use the dedicated print or get_asm method, which supports keyword arguments to
customize behavior.
)"

Definition at line 145 of file IRCore.cpp.

◆ kValueDunderStrDocstring

const char kValueDunderStrDocstring[]
static
Initial value:
=
R"(Returns the string form of the value.
If the value is a block argument, this is the assembly form of its type and the
position in the argument list. If the value is an operation result, this is
equivalent to printing the operation that produced it.
)"

Definition at line 163 of file IRCore.cpp.

◆ kValueReplaceAllUsesWithDocstring

const char kValueReplaceAllUsesWithDocstring[]
static
Initial value:
=
R"(Replace all uses of value with the new value, updating anything in
the IR that uses 'self' to use the other value instead.
)"

Definition at line 175 of file IRCore.cpp.