MLIR 22.0.0git
mlir::DiagnosedSilenceableFailure Class Reference

The result of a transform IR operation application. More...

#include "mlir/Dialect/Transform/Utils/DiagnosedSilenceableFailure.h"

Public Member Functions

 DiagnosedSilenceableFailure (const DiagnosedSilenceableFailure &)=delete
DiagnosedSilenceableFailureoperator= (const DiagnosedSilenceableFailure &)=delete
 DiagnosedSilenceableFailure (DiagnosedSilenceableFailure &&)=default
DiagnosedSilenceableFailureoperator= (DiagnosedSilenceableFailure &&)=default
LogicalResult checkAndReport ()
 Converts all kinds of failure into a LogicalResult failure, emitting the diagnostic if necessary.
bool succeeded () const
 Returns true if this is a success.
bool isDefiniteFailure () const
 Returns true if this is a definite failure.
bool isSilenceableFailure () const
 Returns true if this is a silenceable failure.
std::string getMessage () const
 Returns the diagnostic message without emitting it.
std::string getStatusString () const
 Returns a string representation of the failure mode (for error reporting).
LogicalResult silence ()
 Converts silenceable failure into LogicalResult success without reporting the diagnostic, preserves the other states.
void takeDiagnostics (SmallVectorImpl< Diagnostic > &diags)
 Take the diagnostics and silence.
template<typename T>
DiagnosedSilenceableFailureoperator<< (T &&value) &
 Streams the given values into the last diagnostic.
template<typename T>
DiagnosedSilenceableFailure && operator<< (T &&value) &&
DiagnosticattachNote (std::optional< Location > loc=std::nullopt)
 Attaches a note to the last diagnostic.

Static Public Member Functions

static DiagnosedSilenceableFailure success ()
 Constructs a DiagnosedSilenceableFailure in the success state.
static DiagnosedSilenceableFailure definiteFailure ()
 Constructs a DiagnosedSilenceableFailure in the failure state.
static DiagnosedSilenceableFailure silenceableFailure (Diagnostic &&diag)
 Constructs a DiagnosedSilenceableFailure in the silenceable failure state, ready to emit the given diagnostic.
static DiagnosedSilenceableFailure silenceableFailure (SmallVector< Diagnostic > &&diag)

Detailed Description

The result of a transform IR operation application.

This can have one of the three states:

  • success;
  • silenceable (recoverable) failure with yet-unreported diagnostic;
  • definite failure. Silenceable failure is intended to communicate information about transformations that did not apply but in a way that supports recovery, for example, they did not modify the payload IR or modified it in some predictable way. They are associated with a Diagnostic that provides more details on the failure. Silenceable failure can be discarded, turning the result into success, or "reported", emitting the diagnostic and turning the result into definite failure. Transform IR operations containing other operations are allowed to do either with the results of the nested transformations, but must propagate definite failures as their diagnostics have been already reported to the user.

Definition at line 38 of file DiagnosedSilenceableFailure.h.

Constructor & Destructor Documentation

◆ DiagnosedSilenceableFailure() [1/2]

◆ DiagnosedSilenceableFailure() [2/2]

mlir::DiagnosedSilenceableFailure::DiagnosedSilenceableFailure ( DiagnosedSilenceableFailure && )
default

Member Function Documentation

◆ attachNote()

Diagnostic & mlir::DiagnosedSilenceableFailure::attachNote ( std::optional< Location > loc = std::nullopt)
inline

Attaches a note to the last diagnostic.

Expects this object to be a silenceable failure.

Definition at line 140 of file DiagnosedSilenceableFailure.h.

References isSilenceableFailure().

◆ checkAndReport()

LogicalResult mlir::DiagnosedSilenceableFailure::checkAndReport ( )

Converts all kinds of failure into a LogicalResult failure, emitting the diagnostic if necessary.

Must not be called more than once.

Definition at line 19 of file DiagnosedSilenceableFailure.cpp.

Referenced by mlir::transform::applyTransforms().

◆ definiteFailure()

◆ getMessage()

std::string mlir::DiagnosedSilenceableFailure::getMessage ( ) const
inline

Returns the diagnostic message without emitting it.

Expects this object to be a silenceable failure.

Definition at line 89 of file DiagnosedSilenceableFailure.h.

Referenced by mlir::transform::TransformState::applyTransform().

◆ getStatusString()

std::string mlir::DiagnosedSilenceableFailure::getStatusString ( ) const
inline

Returns a string representation of the failure mode (for error reporting).

Definition at line 99 of file DiagnosedSilenceableFailure.h.

References isSilenceableFailure(), and succeeded().

◆ isDefiniteFailure()

bool mlir::DiagnosedSilenceableFailure::isDefiniteFailure ( ) const
inline

Returns true if this is a definite failure.

Definition at line 80 of file DiagnosedSilenceableFailure.h.

Referenced by mlir::transform::detail::applyTransformToEach().

◆ isSilenceableFailure()

bool mlir::DiagnosedSilenceableFailure::isSilenceableFailure ( ) const
inline

◆ operator<<() [1/2]

template<typename T>
DiagnosedSilenceableFailure & mlir::DiagnosedSilenceableFailure::operator<< ( T && value) &
inline

Streams the given values into the last diagnostic.

Expects this object to be a silenceable failure.

Definition at line 127 of file DiagnosedSilenceableFailure.h.

References DiagnosedSilenceableFailure(), and isSilenceableFailure().

◆ operator<<() [2/2]

template<typename T>
DiagnosedSilenceableFailure && mlir::DiagnosedSilenceableFailure::operator<< ( T && value) &&
inline

Definition at line 134 of file DiagnosedSilenceableFailure.h.

References DiagnosedSilenceableFailure().

◆ operator=() [1/2]

DiagnosedSilenceableFailure & mlir::DiagnosedSilenceableFailure::operator= ( const DiagnosedSilenceableFailure & )
delete

◆ operator=() [2/2]

DiagnosedSilenceableFailure & mlir::DiagnosedSilenceableFailure::operator= ( DiagnosedSilenceableFailure && )
default

◆ silence()

LogicalResult mlir::DiagnosedSilenceableFailure::silence ( )
inline

Converts silenceable failure into LogicalResult success without reporting the diagnostic, preserves the other states.

Definition at line 109 of file DiagnosedSilenceableFailure.h.

Referenced by mlir::transform::TransformState::applyTransform(), and mlir::transform::TransformRewriter::silenceTrackingFailure().

◆ silenceableFailure() [1/2]

DiagnosedSilenceableFailure mlir::DiagnosedSilenceableFailure::silenceableFailure ( Diagnostic && diag)
inlinestatic

Constructs a DiagnosedSilenceableFailure in the silenceable failure state, ready to emit the given diagnostic.

This is considered a failure regardless of the diagnostic severity.

Definition at line 61 of file DiagnosedSilenceableFailure.h.

References diag(), and DiagnosedSilenceableFailure().

Referenced by mlir::transform::detail::applyTransformToEach(), and mlir::transform::ErrorCheckingTrackingListener::notifyPayloadReplacementNotFound().

◆ silenceableFailure() [2/2]

DiagnosedSilenceableFailure mlir::DiagnosedSilenceableFailure::silenceableFailure ( SmallVector< Diagnostic > && diag)
inlinestatic

Definition at line 65 of file DiagnosedSilenceableFailure.h.

References diag(), and DiagnosedSilenceableFailure().

◆ succeeded()

bool mlir::DiagnosedSilenceableFailure::succeeded ( ) const
inline

Returns true if this is a success.

Definition at line 75 of file DiagnosedSilenceableFailure.h.

Referenced by mlir::transform::TransformState::applyTransform(), getStatusString(), and verifyGpuMapping().

◆ success()

DiagnosedSilenceableFailure mlir::DiagnosedSilenceableFailure::success ( )
inlinestatic

◆ takeDiagnostics()

void mlir::DiagnosedSilenceableFailure::takeDiagnostics ( SmallVectorImpl< Diagnostic > & diags)
inline

Take the diagnostics and silence.

Definition at line 118 of file DiagnosedSilenceableFailure.h.

Referenced by mlir::transform::detail::applyTransformToEach().


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