MLIR  19.0.0git
Public Member Functions | List of all members
mlir::tblgen::StaticVerifierFunctionEmitter Class Reference

This class deduplicates shared operation verification code by emitting static functions alongside the op definitions. More...

#include "mlir/TableGen/CodeGenHelpers.h"

Public Member Functions

 StaticVerifierFunctionEmitter (raw_ostream &os, const llvm::RecordKeeper &records)
 
void emitOpConstraints (ArrayRef< llvm::Record * > opDefs, bool emitDecl)
 Collect and unique all compatible type, attribute, successor, and region constraints from the operations in the file and emit them at the top of the generated file. More...
 
void emitPatternConstraints (const ArrayRef< DagLeaf > constraints)
 Unique all compatible type and attribute constraints from a pattern file and emit them at the top of the generated file. More...
 
StringRef getTypeConstraintFn (const Constraint &constraint) const
 Get the name of the static function used for the given type constraint. More...
 
std::optional< StringRef > getAttrConstraintFn (const Constraint &constraint) const
 Get the name of the static function used for the given attribute constraint. More...
 
StringRef getSuccessorConstraintFn (const Constraint &constraint) const
 Get the name of the static function used for the given successor constraint. More...
 
StringRef getRegionConstraintFn (const Constraint &constraint) const
 Get the name of the static function used for the given region constraint. More...
 

Detailed Description

This class deduplicates shared operation verification code by emitting static functions alongside the op definitions.

These methods are local to the definition file, and are invoked within the operation verify methods. An example is shown below:

static LogicalResult localVerify(...)

LogicalResult OpA::verify(...) { if (failed(localVerify(...))) return failure(); ... }

LogicalResult OpB::verify(...) { if (failed(localVerify(...))) return failure(); ... }

Definition at line 100 of file CodeGenHelpers.h.

Constructor & Destructor Documentation

◆ StaticVerifierFunctionEmitter()

StaticVerifierFunctionEmitter::StaticVerifierFunctionEmitter ( raw_ostream &  os,
const llvm::RecordKeeper &  records 
)

Definition at line 46 of file CodeGenHelpers.cpp.

Member Function Documentation

◆ emitOpConstraints()

void StaticVerifierFunctionEmitter::emitOpConstraints ( ArrayRef< llvm::Record * >  opDefs,
bool  emitDecl 
)

Collect and unique all compatible type, attribute, successor, and region constraints from the operations in the file and emit them at the top of the generated file.

Constraints that do not meet the restriction that they can only reference $_self and $_op are not uniqued.

Definition at line 50 of file CodeGenHelpers.cpp.

◆ emitPatternConstraints()

void StaticVerifierFunctionEmitter::emitPatternConstraints ( const ArrayRef< DagLeaf constraints)

Unique all compatible type and attribute constraints from a pattern file and emit them at the top of the generated file.

Constraints that do not meet the restriction that they can only reference $_self, $_op, and $_builder are not uniqued.

Definition at line 63 of file CodeGenHelpers.cpp.

References emitPatternConstraints().

Referenced by emitPatternConstraints().

◆ getAttrConstraintFn()

std::optional< StringRef > StaticVerifierFunctionEmitter::getAttrConstraintFn ( const Constraint constraint) const

Get the name of the static function used for the given attribute constraint.

These functions are in the form:

LogicalResult(Operation *op, Attribute attr, StringRef attrName);

If a uniqued constraint was not found, this function returns std::nullopt. The uniqued constraints cannot be used in the context of an OpAdaptor.

Pattern constraints have the form:

LogicalResult(PatternRewriter &rewriter, Operation *op, Attribute attr, StringRef failureStr);

Definition at line 81 of file CodeGenHelpers.cpp.

◆ getRegionConstraintFn()

StringRef StaticVerifierFunctionEmitter::getRegionConstraintFn ( const Constraint constraint) const

Get the name of the static function used for the given region constraint.

These functions are in the form:

LogicalResult(Operation *op, Region &region, StringRef regionName, unsigned regionIndex);

The region name may be empty.

Definition at line 96 of file CodeGenHelpers.cpp.

◆ getSuccessorConstraintFn()

StringRef StaticVerifierFunctionEmitter::getSuccessorConstraintFn ( const Constraint constraint) const

Get the name of the static function used for the given successor constraint.

These functions are in the form:

LogicalResult(Operation *op, Block *successor, StringRef successorName, unsigned successorIndex);

Definition at line 88 of file CodeGenHelpers.cpp.

◆ getTypeConstraintFn()

StringRef StaticVerifierFunctionEmitter::getTypeConstraintFn ( const Constraint constraint) const

Get the name of the static function used for the given type constraint.

These functions are used for operand and result constraints and have the form:

LogicalResult(Operation *op, Type type, StringRef valueKind, unsigned valueIndex);

Pattern constraints have the form:

LogicalResult(PatternRewriter &rewriter, Operation *op, Type type, StringRef failureStr);

Definition at line 72 of file CodeGenHelpers.cpp.


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