MLIR 24.0.0git
Remarks.cpp File Reference
#include "mlir-c/Remarks.h"
#include "mlir/CAPI/IR.h"
#include "mlir/CAPI/Remarks.h"
#include "mlir/CAPI/Support.h"
#include "mlir/CAPI/Utils.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Remarks.h"
#include "mlir/Remark/RemarkStreamer.h"
#include "llvm/Remarks/RemarkFormat.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <memory>

Go to the source code of this file.

Classes

class  Remark

Functions

static remark::RemarkCategories unwrap (MlirRemarkCategories categories)
 Every filter reaches the engine as a (possibly empty) string, as with mlir-opt's options: a kind is reported when its own filter or all matches.
static std::unique_ptr< remark::detail::RemarkEmittingPolicyBase > createPolicy (MlirRemarkPolicy policy)
static llvm::remarks::Format unwrap (MlirRemarkFileFormat format)
static MlirRemarkKind wrap (remark::RemarkKind kind)
MlirLogicalResult mlirContextEnableOptimizationRemarks (MlirContext context, MlirRemarkCategories categories, MlirRemarkPolicy policy, bool printAsEmitRemarks)
 Enables the remark engine on the context without a streamer; when printAsEmitRemarks is set, every reported remark is emitted as an MLIR remark diagnostic at its location.
MlirLogicalResult mlirContextEnableOptimizationRemarksToFile (MlirContext context, MlirRemarkCategories categories, MlirRemarkPolicy policy, MlirRemarkFileFormat format, MlirStringRef path, bool printAsEmitRemarks)
 Enables the remark engine on the context, streaming the reported remarks to the file at path in format.
MlirLogicalResult mlirContextEnableOptimizationRemarksWithCallback (MlirContext context, MlirRemarkCategories categories, MlirRemarkPolicy policy, MlirRemarkCallback callback, void *userData, void(*deleteUserData)(void *), bool printAsEmitRemarks)
 Enables the remark engine on the context, delivering every reported remark to callback.
void mlirContextFinalizeOptimizationRemarks (MlirContext context)
 Finalizes and removes the remark engine of the context: postponed remarks are reported, the output file is written and the callback's user data is released.
bool mlirContextHasRemarkEngine (MlirContext context)
 Returns whether the context has a remark engine enabled.
MlirRemarkKind mlirRemarkGetKind (MlirRemark remark)
 Returns the kind of the remark.
MlirStringRef mlirRemarkGetRemarkName (MlirRemark remark)
 Returns the name identifying the remark.
MlirStringRef mlirRemarkGetCategoryName (MlirRemark remark)
 Returns the category of the remark (the subject of the filters).
MlirStringRef mlirRemarkGetFullCategoryName (MlirRemark remark)
 Returns the combined category:subcategory name of the remark.
MlirStringRef mlirRemarkGetFunctionName (MlirRemark remark)
 Returns the name of the function the remark refers to.
MlirLocation mlirRemarkGetLocation (MlirRemark remark)
 Returns the location of the remark.
uint64_t mlirRemarkGetId (MlirRemark remark)
 Returns the unique id of the remark within its engine (0 when unset).
intptr_t mlirRemarkGetNumArgs (MlirRemark remark)
 Returns the number of key/value arguments attached to the remark.
MlirStringRef mlirRemarkGetArgKey (MlirRemark remark, intptr_t pos)
 Returns the key of the pos-th argument of the remark.
MlirStringRef mlirRemarkGetArgValue (MlirRemark remark, intptr_t pos)
 Returns the value of the pos-th argument of the remark.
void mlirRemarkPrint (MlirRemark remark, MlirStringCallback callback, void *userData)
 Prints the remark in its textual form, [Kind] name | Category:... | / Function=... | key=value, ... (without its location).
bool mlirEmitOptimizationRemark (MlirLocation location, MlirRemarkKind kind, MlirStringRef remarkName, MlirStringRef categoryName, MlirStringRef subCategoryName, MlirStringRef functionName, MlirStringRef message, intptr_t numArgs, const MlirStringRef *argKeys, const MlirStringRef *argValues)
 Emits a remark of kind at location through the remark engine of the location's context.

Function Documentation

◆ createPolicy()

◆ mlirContextEnableOptimizationRemarks()

MlirLogicalResult mlirContextEnableOptimizationRemarks ( MlirContext context,
MlirRemarkCategories categories,
MlirRemarkPolicy policy,
bool printAsEmitRemarks )

Enables the remark engine on the context without a streamer; when printAsEmitRemarks is set, every reported remark is emitted as an MLIR remark diagnostic at its location.

Fails when the context already has a remark engine (finalize it first).

Definition at line 105 of file Remarks.cpp.

References createPolicy(), mlir::remark::enableOptimizationRemarks(), mlir::MLIRContext::getRemarkEngine(), mlirLogicalResultFailure(), unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::enableRemarks().

◆ mlirContextEnableOptimizationRemarksToFile()

MlirLogicalResult mlirContextEnableOptimizationRemarksToFile ( MlirContext context,
MlirRemarkCategories categories,
MlirRemarkPolicy policy,
MlirRemarkFileFormat format,
MlirStringRef path,
bool printAsEmitRemarks )

Enables the remark engine on the context, streaming the reported remarks to the file at path in format.

The file is written when the engine is finalized. Fails when the file cannot be created or the context already has a remark engine.

Definition at line 116 of file Remarks.cpp.

References createPolicy(), mlir::remark::enableOptimizationRemarksWithLLVMStreamer(), mlir::MLIRContext::getRemarkEngine(), mlirLogicalResultFailure(), unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::enableRemarks().

◆ mlirContextEnableOptimizationRemarksWithCallback()

MlirLogicalResult mlirContextEnableOptimizationRemarksWithCallback ( MlirContext context,
MlirRemarkCategories categories,
MlirRemarkPolicy policy,
MlirRemarkCallback callback,
void * userData,
void(* deleteUserData )(void *),
bool printAsEmitRemarks )

Enables the remark engine on the context, delivering every reported remark to callback.

userData is passed to the callback unchanged and released through deleteUserData (may be null) when the engine is finalized or the context is destroyed. Fails when the context already has a remark engine.

Definition at line 128 of file Remarks.cpp.

References createPolicy(), mlir::remark::enableOptimizationRemarks(), mlir::MLIRContext::getRemarkEngine(), mlirLogicalResultFailure(), unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::enableRemarks().

◆ mlirContextFinalizeOptimizationRemarks()

void mlirContextFinalizeOptimizationRemarks ( MlirContext context)

Finalizes and removes the remark engine of the context: postponed remarks are reported, the output file is written and the callback's user data is released.

Does nothing when no engine is enabled.

Definition at line 147 of file Remarks.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::finalizeRemarks().

◆ mlirContextHasRemarkEngine()

bool mlirContextHasRemarkEngine ( MlirContext context)

Returns whether the context has a remark engine enabled.

Definition at line 153 of file Remarks.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::enableRemarks(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::getRemarksEnabled().

◆ mlirEmitOptimizationRemark()

bool mlirEmitOptimizationRemark ( MlirLocation location,
MlirRemarkKind kind,
MlirStringRef remarkName,
MlirStringRef categoryName,
MlirStringRef subCategoryName,
MlirStringRef functionName,
MlirStringRef message,
intptr_t numArgs,
const MlirStringRef * argKeys,
const MlirStringRef * argValues )

Emits a remark of kind at location through the remark engine of the location's context.

message (when non-empty) and the numArgs key/value pairs become the arguments of the remark. Returns false, emitting nothing, when the context has no remark engine, the category is filtered out, or kind is MlirRemarkKindUnknown.

Definition at line 217 of file Remarks.cpp.

References mlir::remark::analysis(), mlir::remark::RemarkOpts::category(), mlir::remark::failed(), mlir::remark::RemarkOpts::function(), MlirStringRef::length, mlir::remark::missed(), MlirRemarkKindAnalysis, MlirRemarkKindFailure, MlirRemarkKindMissed, MlirRemarkKindPassed, MlirRemarkKindUnknown, mlir::remark::RemarkOpts::name(), mlir::remark::passed(), mlir::remark::RemarkOpts::subCategory(), and unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ mlirRemarkGetArgKey()

MlirStringRef mlirRemarkGetArgKey ( MlirRemark remark,
intptr_t pos )

Returns the key of the pos-th argument of the remark.

Definition at line 193 of file Remarks.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getArgs().

◆ mlirRemarkGetArgValue()

MlirStringRef mlirRemarkGetArgValue ( MlirRemark remark,
intptr_t pos )

Returns the value of the pos-th argument of the remark.

Definition at line 200 of file Remarks.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getArgs().

◆ mlirRemarkGetCategoryName()

MlirStringRef mlirRemarkGetCategoryName ( MlirRemark remark)

Returns the category of the remark (the subject of the filters).

Definition at line 169 of file Remarks.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getCategoryName().

◆ mlirRemarkGetFullCategoryName()

MlirStringRef mlirRemarkGetFullCategoryName ( MlirRemark remark)

Returns the combined category:subcategory name of the remark.

Definition at line 173 of file Remarks.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getFullCategoryName().

◆ mlirRemarkGetFunctionName()

MlirStringRef mlirRemarkGetFunctionName ( MlirRemark remark)

Returns the name of the function the remark refers to.

Definition at line 177 of file Remarks.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getFunctionName().

◆ mlirRemarkGetId()

uint64_t mlirRemarkGetId ( MlirRemark remark)

Returns the unique id of the remark within its engine (0 when unset).

Definition at line 185 of file Remarks.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getId().

◆ mlirRemarkGetKind()

MlirRemarkKind mlirRemarkGetKind ( MlirRemark remark)

Returns the kind of the remark.

Definition at line 161 of file Remarks.cpp.

References getRemarkKind(), unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getKind().

◆ mlirRemarkGetLocation()

MlirLocation mlirRemarkGetLocation ( MlirRemark remark)

Returns the location of the remark.

Definition at line 181 of file Remarks.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getLocation().

◆ mlirRemarkGetNumArgs()

intptr_t mlirRemarkGetNumArgs ( MlirRemark remark)

Returns the number of key/value arguments attached to the remark.

Definition at line 189 of file Remarks.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getArgs().

◆ mlirRemarkGetRemarkName()

MlirStringRef mlirRemarkGetRemarkName ( MlirRemark remark)

Returns the name identifying the remark.

Definition at line 165 of file Remarks.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getRemarkName().

◆ mlirRemarkPrint()

void mlirRemarkPrint ( MlirRemark remark,
MlirStringCallback callback,
void * userData )

Prints the remark in its textual form, [Kind] name | Category:... | / Function=... | key=value, ... (without its location).

Definition at line 207 of file Remarks.cpp.

References unwrap().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRemark::getMessage().

◆ unwrap() [1/2]

◆ unwrap() [2/2]

llvm::remarks::Format unwrap ( MlirRemarkFileFormat format)
static

Definition at line 75 of file Remarks.cpp.

References MlirRemarkFileFormatBitstream, and MlirRemarkFileFormatYAML.

◆ wrap()