MLIR 24.0.0git
Remarks.h File Reference
#include "mlir-c/IR.h"
#include "mlir-c/Support.h"

Go to the source code of this file.

Classes

struct  MlirRemark
 An opaque reference to a remark. More...
struct  MlirRemarkCategories
 Regular expressions (llvm::Regex syntax, anchored by the engine) selecting the remark categories to report: all applies to every kind, the others to one kind each. More...

Typedefs

typedef struct MlirRemark MlirRemark
typedef enum MlirRemarkKind MlirRemarkKind
typedef enum MlirRemarkPolicy MlirRemarkPolicy
typedef enum MlirRemarkFileFormat MlirRemarkFileFormat
typedef struct MlirRemarkCategories MlirRemarkCategories
typedef void(* MlirRemarkCallback) (MlirRemark remark, void *userData)
 Callback receiving every remark the engine reports.

Enumerations

enum  MlirRemarkKind {
  MlirRemarkKindUnknown , MlirRemarkKindPassed , MlirRemarkKindMissed , MlirRemarkKindFailure ,
  MlirRemarkKindAnalysis
}
 The outcome a remark describes (see mlir::remark::RemarkKind). More...
enum  MlirRemarkPolicy { MlirRemarkPolicyAll , MlirRemarkPolicyFinal }
 The emitting policy of the remark engine. More...
enum  MlirRemarkFileFormat { MlirRemarkFileFormatYAML , MlirRemarkFileFormatBitstream }
 The serialization format of a remark output file. More...

Functions

MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED bool mlirContextHasRemarkEngine (MlirContext context)
 Returns whether the context has a remark engine enabled.
MLIR_CAPI_EXPORTED MlirRemarkKind mlirRemarkGetKind (MlirRemark remark)
 Returns the kind of the remark.
MLIR_CAPI_EXPORTED MlirStringRef mlirRemarkGetRemarkName (MlirRemark remark)
 Returns the name identifying the remark.
MLIR_CAPI_EXPORTED MlirStringRef mlirRemarkGetCategoryName (MlirRemark remark)
 Returns the category of the remark (the subject of the filters).
MLIR_CAPI_EXPORTED MlirStringRef mlirRemarkGetFullCategoryName (MlirRemark remark)
 Returns the combined category:subcategory name of the remark.
MLIR_CAPI_EXPORTED MlirStringRef mlirRemarkGetFunctionName (MlirRemark remark)
 Returns the name of the function the remark refers to.
MLIR_CAPI_EXPORTED MlirLocation mlirRemarkGetLocation (MlirRemark remark)
 Returns the location of the remark.
MLIR_CAPI_EXPORTED uint64_t mlirRemarkGetId (MlirRemark remark)
 Returns the unique id of the remark within its engine (0 when unset).
MLIR_CAPI_EXPORTED intptr_t mlirRemarkGetNumArgs (MlirRemark remark)
 Returns the number of key/value arguments attached to the remark.
MLIR_CAPI_EXPORTED MlirStringRef mlirRemarkGetArgKey (MlirRemark remark, intptr_t pos)
 Returns the key of the pos-th argument of the remark.
MLIR_CAPI_EXPORTED MlirStringRef mlirRemarkGetArgValue (MlirRemark remark, intptr_t pos)
 Returns the value of the pos-th argument of the remark.
MLIR_CAPI_EXPORTED void mlirRemarkPrint (MlirRemark remark, MlirStringCallback callback, void *userData)
 Prints the remark in its textual form, [Kind] name | Category:... | / Function=... | key=value, ... (without its location).
MLIR_CAPI_EXPORTED 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.

Typedef Documentation

◆ MlirRemark

typedef struct MlirRemark MlirRemark

Definition at line 35 of file Remarks.h.

◆ MlirRemarkCallback

typedef void(* MlirRemarkCallback) (MlirRemark remark, void *userData)

Callback receiving every remark the engine reports.

Definition at line 82 of file Remarks.h.

◆ MlirRemarkCategories

typedef struct MlirRemarkCategories MlirRemarkCategories

Definition at line 79 of file Remarks.h.

◆ MlirRemarkFileFormat

Definition at line 66 of file Remarks.h.

◆ MlirRemarkKind

Definition at line 49 of file Remarks.h.

◆ MlirRemarkPolicy

Definition at line 59 of file Remarks.h.

Enumeration Type Documentation

◆ MlirRemarkFileFormat

The serialization format of a remark output file.

Enumerator
MlirRemarkFileFormatYAML 
MlirRemarkFileFormatBitstream 

Definition at line 62 of file Remarks.h.

◆ MlirRemarkKind

The outcome a remark describes (see mlir::remark::RemarkKind).

Enumerator
MlirRemarkKindUnknown 
MlirRemarkKindPassed 

An optimization was applied.

MlirRemarkKindMissed 

A profitable optimization opportunity was found but not applied.

MlirRemarkKindFailure 

The optimization was attempted but failed.

MlirRemarkKindAnalysis 

Informational context without a pass/fail outcome.

Definition at line 38 of file Remarks.h.

◆ MlirRemarkPolicy

The emitting policy of the remark engine.

Enumerator
MlirRemarkPolicyAll 

Report every remark as it is emitted.

MlirRemarkPolicyFinal 

Postpone remarks and report the final set when the engine is finalized, grouping related remarks under their parents.

Definition at line 52 of file Remarks.h.

Function Documentation

◆ mlirContextEnableOptimizationRemarks()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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()

MLIR_CAPI_EXPORTED 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().