MLIR
20.0.0git
|
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, StringRef tag="") | |
Create a constraint uniquer with a unique prefix derived from the record keeper with an optional tag. More... | |
void | collectOpConstraints (ArrayRef< const llvm::Record * > opDefs) |
Collect and unique all the constraints used by operations. More... | |
void | emitOpConstraints (ArrayRef< const llvm::Record * > opDefs) |
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... | |
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.
StaticVerifierFunctionEmitter::StaticVerifierFunctionEmitter | ( | raw_ostream & | os, |
const llvm::RecordKeeper & | records, | ||
StringRef | tag = "" |
||
) |
Create a constraint uniquer with a unique prefix derived from the record keeper with an optional tag.
Definition at line 47 of file CodeGenHelpers.cpp.
void StaticVerifierFunctionEmitter::collectOpConstraints | ( | ArrayRef< const llvm::Record * > | opDefs | ) |
Collect and unique all the constraints used by operations.
Collect type constraints.
Collect attribute constraints.
Collect successor constraints.
Collect region constraints.
Definition at line 266 of file CodeGenHelpers.cpp.
References canUniqueAttrConstraint(), mlir::tblgen::Operator::getAttributes(), mlir::tblgen::Operator::getOperands(), mlir::tblgen::Operator::getRegions(), mlir::tblgen::Operator::getResults(), and mlir::tblgen::Operator::getSuccessors().
void StaticVerifierFunctionEmitter::emitOpConstraints | ( | ArrayRef< const llvm::Record * > | opDefs | ) |
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 51 of file CodeGenHelpers.cpp.
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 60 of file CodeGenHelpers.cpp.
References emitPatternConstraints().
Referenced by emitPatternConstraints().
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 78 of file CodeGenHelpers.cpp.
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 ®ion, StringRef regionName, unsigned regionIndex);
The region name may be empty.
Definition at line 93 of file CodeGenHelpers.cpp.
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 85 of file CodeGenHelpers.cpp.
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 69 of file CodeGenHelpers.cpp.