From 6895a1c37e44f286138b9d57e5d15467d278ec75 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Tue, 28 Jan 2020 10:21:12 +0100 Subject: [PATCH] [mlir] NFC: use doxygen-style comments in AffineToStandard.cpp --- .../AffineToStandard/AffineToStandard.cpp | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index cea17acaedb3..ff4196ffdb23 100644 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -29,14 +29,14 @@ using namespace mlir; namespace { -// Visit affine expressions recursively and build the sequence of operations -// that correspond to it. Visitation functions return an Value of the -// expression subtree they visited or `nullptr` on error. +/// Visit affine expressions recursively and build the sequence of operations +/// that correspond to it. Visitation functions return an Value of the +/// expression subtree they visited or `nullptr` on error. class AffineApplyExpander : public AffineExprVisitor { public: - // This internal class expects arguments to be non-null, checks must be - // performed at the call site. + /// This internal class expects arguments to be non-null, checks must be + /// performed at the call site. AffineApplyExpander(OpBuilder &builder, ArrayRef dimValues, ArrayRef symbolValues, Location loc) : builder(builder), dimValues(dimValues), symbolValues(symbolValues), @@ -59,15 +59,15 @@ public: return buildBinaryExpr(expr); } - // Euclidean modulo operation: negative RHS is not allowed. - // Remainder of the euclidean integer division is always non-negative. - // - // Implemented as - // - // a mod b = - // let remainder = srem a, b; - // negative = a < 0 in - // select negative, remainder + b, remainder. + /// Euclidean modulo operation: negative RHS is not allowed. + /// Remainder of the euclidean integer division is always non-negative. + /// + /// Implemented as + /// + /// a mod b = + /// let remainder = srem a, b; + /// negative = a < 0 in + /// select negative, remainder + b, remainder. Value visitModExpr(AffineBinaryOpExpr expr) { auto rhsConst = expr.getRHS().dyn_cast(); if (!rhsConst) { @@ -95,16 +95,16 @@ public: return result; } - // Floor division operation (rounds towards negative infinity). - // - // For positive divisors, it can be implemented without branching and with a - // single division operation as - // - // a floordiv b = - // let negative = a < 0 in - // let absolute = negative ? -a - 1 : a in - // let quotient = absolute / b in - // negative ? -quotient - 1 : quotient + /// Floor division operation (rounds towards negative infinity). + /// + /// For positive divisors, it can be implemented without branching and with a + /// single division operation as + /// + /// a floordiv b = + /// let negative = a < 0 in + /// let absolute = negative ? -a - 1 : a in + /// let quotient = absolute / b in + /// negative ? -quotient - 1 : quotient Value visitFloorDivExpr(AffineBinaryOpExpr expr) { auto rhsConst = expr.getRHS().dyn_cast(); if (!rhsConst) { @@ -136,16 +136,16 @@ public: return result; } - // Ceiling division operation (rounds towards positive infinity). - // - // For positive divisors, it can be implemented without branching and with a - // single division operation as - // - // a ceildiv b = - // let negative = a <= 0 in - // let absolute = negative ? -a : a - 1 in - // let quotient = absolute / b in - // negative ? -quotient : quotient + 1 + /// Ceiling division operation (rounds towards positive infinity). + /// + /// For positive divisors, it can be implemented without branching and with a + /// single division operation as + /// + /// a ceildiv b = + /// let negative = a <= 0 in + /// let absolute = negative ? -a : a - 1 in + /// let quotient = absolute / b in + /// negative ? -quotient : quotient + 1 Value visitCeilDivExpr(AffineBinaryOpExpr expr) { auto rhsConst = expr.getRHS().dyn_cast(); if (!rhsConst) { @@ -206,16 +206,16 @@ private: }; } // namespace -// Create a sequence of operations that implement the `expr` applied to the -// given dimension and symbol values. +/// Create a sequence of operations that implement the `expr` applied to the +/// given dimension and symbol values. mlir::Value mlir::expandAffineExpr(OpBuilder &builder, Location loc, AffineExpr expr, ArrayRef dimValues, ArrayRef symbolValues) { return AffineApplyExpander(builder, dimValues, symbolValues, loc).visit(expr); } -// Create a sequence of operations that implement the `affineMap` applied to -// the given `operands` (as it it were an AffineApplyOp). +/// Create a sequence of operations that implement the `affineMap` applied to +/// the given `operands` (as it it were an AffineApplyOp). Optional> static expandAffineMap( OpBuilder &builder, Location loc, AffineMap affineMap, ArrayRef operands) { @@ -232,17 +232,17 @@ Optional> static expandAffineMap( return None; } -// Given a range of values, emit the code that reduces them with "min" or "max" -// depending on the provided comparison predicate. The predicate defines which -// comparison to perform, "lt" for "min", "gt" for "max" and is used for the -// `cmpi` operation followed by the `select` operation: -// -// %cond = cmpi "predicate" %v0, %v1 -// %result = select %cond, %v0, %v1 -// -// Multiple values are scanned in a linear sequence. This creates a data -// dependences that wouldn't exist in a tree reduction, but is easier to -// recognize as a reduction by the subsequent passes. +/// Given a range of values, emit the code that reduces them with "min" or "max" +/// depending on the provided comparison predicate. The predicate defines which +/// comparison to perform, "lt" for "min", "gt" for "max" and is used for the +/// `cmpi` operation followed by the `select` operation: +/// +/// %cond = cmpi "predicate" %v0, %v1 +/// %result = select %cond, %v0, %v1 +/// +/// Multiple values are scanned in a linear sequence. This creates a data +/// dependences that wouldn't exist in a tree reduction, but is easier to +/// recognize as a reduction by the subsequent passes. static Value buildMinMaxReductionSeq(Location loc, CmpIPredicate predicate, ArrayRef values, OpBuilder &builder) { @@ -258,9 +258,9 @@ static Value buildMinMaxReductionSeq(Location loc, CmpIPredicate predicate, return value; } -// Emit instructions that correspond to the affine map in the lower bound -// applied to the respective operands, and compute the maximum value across -// the results. +/// Emit instructions that correspond to the affine map in the lower bound +/// applied to the respective operands, and compute the maximum value across +/// the results. Value mlir::lowerAffineLowerBound(AffineForOp op, OpBuilder &builder) { SmallVector boundOperands(op.getLowerBoundOperands()); auto lbValues = expandAffineMap(builder, op.getLoc(), op.getLowerBoundMap(), @@ -271,8 +271,8 @@ Value mlir::lowerAffineLowerBound(AffineForOp op, OpBuilder &builder) { builder); } -// Emit instructions that correspond to computing the minimum value amoung the -// values of a (potentially) multi-output affine map applied to `operands`. +/// Emit instructions that correspond to computing the minimum value amoung the +/// values of a (potentially) multi-output affine map applied to `operands`. static Value lowerAffineMapMin(OpBuilder &builder, Location loc, AffineMap map, ValueRange operands) { if (auto values = @@ -281,9 +281,9 @@ static Value lowerAffineMapMin(OpBuilder &builder, Location loc, AffineMap map, return nullptr; } -// Emit instructions that correspond to the affine map in the upper bound -// applied to the respective operands, and compute the minimum value across -// the results. +/// Emit instructions that correspond to the affine map in the upper bound +/// applied to the respective operands, and compute the minimum value across +/// the results. Value mlir::lowerAffineUpperBound(AffineForOp op, OpBuilder &builder) { return lowerAffineMapMin(builder, op.getLoc(), op.getUpperBoundMap(), op.getUpperBoundOperands()); @@ -306,7 +306,7 @@ public: } }; -// Affine terminators are removed. +/// Affine terminators are removed. class AffineTerminatorLowering : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; @@ -387,8 +387,8 @@ public: } }; -// Convert an "affine.apply" operation into a sequence of arithmetic -// operations using the StandardOps dialect. +/// Convert an "affine.apply" operation into a sequence of arithmetic +/// operations using the StandardOps dialect. class AffineApplyLowering : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; @@ -405,9 +405,9 @@ public: } }; -// Apply the affine map from an 'affine.load' operation to its operands, and -// feed the results to a newly created 'std.load' operation (which replaces the -// original 'affine.load'). +/// Apply the affine map from an 'affine.load' operation to its operands, and +/// feed the results to a newly created 'std.load' operation (which replaces the +/// original 'affine.load'). class AffineLoadLowering : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; @@ -427,9 +427,9 @@ public: } }; -// Apply the affine map from an 'affine.prefetch' operation to its operands, and -// feed the results to a newly created 'std.prefetch' operation (which replaces -// the original 'affine.prefetch'). +/// Apply the affine map from an 'affine.prefetch' operation to its operands, +/// and feed the results to a newly created 'std.prefetch' operation (which +/// replaces the original 'affine.prefetch'). class AffinePrefetchLowering : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; @@ -451,9 +451,9 @@ public: } }; -// Apply the affine map from an 'affine.store' operation to its operands, and -// feed the results to a newly created 'std.store' operation (which replaces the -// original 'affine.store'). +/// Apply the affine map from an 'affine.store' operation to its operands, and +/// feed the results to a newly created 'std.store' operation (which replaces +/// the original 'affine.store'). class AffineStoreLowering : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; @@ -474,9 +474,9 @@ public: } }; -// Apply the affine maps from an 'affine.dma_start' operation to each of their -// respective map operands, and feed the results to a newly created -// 'std.dma_start' operation (which replaces the original 'affine.dma_start'). +/// Apply the affine maps from an 'affine.dma_start' operation to each of their +/// respective map operands, and feed the results to a newly created +/// 'std.dma_start' operation (which replaces the original 'affine.dma_start'). class AffineDmaStartLowering : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; @@ -514,9 +514,9 @@ public: } }; -// Apply the affine map from an 'affine.dma_wait' operation tag memref, -// and feed the results to a newly created 'std.dma_wait' operation (which -// replaces the original 'affine.dma_wait'). +/// Apply the affine map from an 'affine.dma_wait' operation tag memref, +/// and feed the results to a newly created 'std.dma_wait' operation (which +/// replaces the original 'affine.dma_wait'). class AffineDmaWaitLowering : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern;