Class ForOp

Inheritance Relationships

Base Type

  • public mlir::Op< ForOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::NoTerminator, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::OpAsmOpInterface::Trait >

Class Documentation

class ForOp : public mlir::Op<ForOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::NoTerminator, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::OpAsmOpInterface::Trait>

Public Types

using Adaptor = ForOpAdaptor
template<typename RangeT>
using GenericAdaptor = ForOpGenericAdaptor<RangeT>
using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>
using Properties = FoldAdaptor::Properties

Public Functions

inline ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames()
inline ::mlir::StringAttr getLowerBoundAttrName()
inline ::mlir::StringAttr getStepAttrName()
inline ::mlir::StringAttr getUpperBoundAttrName()
inline std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index)
inline ::mlir::Operation::operand_range getODSOperands(unsigned index)
inline std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index)
inline ::mlir::Operation::result_range getODSResults(unsigned index)
inline ::mlir::Region &getBody()
void writeProperties(::mlir::DialectBytecodeWriter &writer)
inline ::mlir::IntegerAttr getLowerBoundAttr()
::llvm::APInt getLowerBound()
inline ::mlir::IntegerAttr getUpperBoundAttr()
::llvm::APInt getUpperBound()
inline ::mlir::IntegerAttr getStepAttr()
::llvm::APInt getStep()
inline void setLowerBoundAttr(::mlir::IntegerAttr attr)
void setLowerBound(::llvm::APInt attrValue)
inline void setUpperBoundAttr(::mlir::IntegerAttr attr)
void setUpperBound(::llvm::APInt attrValue)
inline void setStepAttr(::mlir::IntegerAttr attr)
void setStep(::llvm::APInt attrValue)
void print(::mlir::OpAsmPrinter &p)

Prints an emithls::ForOp in the custom assembly syntax consumed by parse.

::llvm::LogicalResult verifyInvariantsImpl()
::llvm::LogicalResult verifyInvariants()
::llvm::LogicalResult verify()

Verifies an emithls::ForOp has valid bounds and a non-empty body.

Rejects loops where:

  • lower bound equals upper bound (zero iterations),

  • step is zero,

  • upper bound is unreachable from lower bound in at least one step, or

  • the body region is empty.

void getAsmBlockArgumentNames(::mlir::Region &region, ::mlir::OpAsmSetValueNameFn setNameFn)

Names the induction-variable block argument.

Assigns a name of the form idx<N> where N is the zero-based nesting depth, so the outermost loop uses idx0, its immediate child idx1, and so on.

inline Value getInductionVariable()
inline int64_t getTripCount()

Public Static Functions

static inline ::mlir::StringAttr getLowerBoundAttrName(::mlir::OperationName name)
static inline ::mlir::StringAttr getStepAttrName(::mlir::OperationName name)
static inline ::mlir::StringAttr getUpperBoundAttrName(::mlir::OperationName name)
static inline constexpr ::llvm::StringLiteral getOperationName()
static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
static llvm::hash_code computePropertiesHash(const Properties &prop)
static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, int64_t lowerBound, int64_t upperBound, int64_t step = 1, function_ref<void(OpBuilder&, Location, ValueRange)> bodyBuilder = nullptr)
static ForOp create(::mlir::OpBuilder &builder, ::mlir::Location location, int64_t lowerBound, int64_t upperBound, int64_t step = 1, function_ref<void(OpBuilder&, Location, ValueRange)> bodyBuilder = nullptr)
static ForOp create(::mlir::ImplicitLocOpBuilder &builder, int64_t lowerBound, int64_t upperBound, int64_t step = 1, function_ref<void(OpBuilder&, Location, ValueRange)> bodyBuilder = nullptr)
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Attribute lowerBound, Attribute upperBound, Attribute step, function_ref<void(OpBuilder&, Location, ValueRange)> bodyBuilder = nullptr)
static ForOp create(::mlir::OpBuilder &builder, ::mlir::Location location, Attribute lowerBound, Attribute upperBound, Attribute step, function_ref<void(OpBuilder&, Location, ValueRange)> bodyBuilder = nullptr)
static ForOp create(::mlir::ImplicitLocOpBuilder &builder, Attribute lowerBound, Attribute upperBound, Attribute step, function_ref<void(OpBuilder&, Location, ValueRange)> bodyBuilder = nullptr)
static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)

Parses an emithls::ForOp from its custom assembly syntax.

The expected syntax is:

`emithls.for` induction-var `=` lower-bound `to` upper-bound
                                `step` step body-region

All bounds and the step are index-typed integer attributes. The induction variable is added as a block argument to the body region.

static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context)

Canonicalization patterns for ForOp.

  • RemoveTrivialLoop: inlines the body of a single-iteration loop, replacing the induction variable with a constant, then erases the loop.

  • CollapseUnusedOuterLoop: folds a loop whose induction variable is unused and whose body is nothing but another loop into that inner loop’s trip count, eliminating the pointless wrapping level of nesting.

static ::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)