Commit c4119a5b authored by Frank Laub's avatar Frank Laub
Browse files

[MLIR][Affine][NFC] Remove obsolete and ambiguous definitions

Summary:
Looks like a refactor that was never completed.

This change removes some unused and ambiguous definitions.

Reviewed By: bondhugula, nicolasvasilache, rriddle

Differential Revision: https://reviews.llvm.org/D75586
parent a27f29c6
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -660,13 +660,6 @@ private:
  constexpr static unsigned kExplosionFactor = 32;
};

/// Simplify an affine expression by flattening and some amount of
/// simple analysis. This has complexity linear in the number of nodes in
/// 'expr'. Returns the simplified expression, which is the same as the input
///  expression if it can't be simplified.
AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims,
                              unsigned numSymbols);

/// Flattens 'expr' into 'flattenedExpr', which contains the coefficients of the
/// dimensions, symbols, and additional variables that represent floor divisions
/// of dimensions, symbols, and in turn other floor divisions.  Returns failure
+0 −20
Original line number Diff line number Diff line
@@ -250,26 +250,6 @@ template <typename U> U AffineExpr::cast() const {
AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims,
                              unsigned numSymbols);

/// Flattens 'expr' into 'flattenedExpr'. Returns true on success or false
/// if 'expr' could not be flattened (i.e., semi-affine is not yet handled).
/// See documentation for AffineExprFlattener on how mod's and div's are
/// flattened.
bool getFlattenedAffineExpr(AffineExpr expr, unsigned numDims,
                            unsigned numSymbols,
                            SmallVectorImpl<int64_t> *flattenedExpr);

/// Flattens the result expressions of the map to their corresponding flattened
/// forms and set in 'flattenedExprs'. Returns true on success or false
/// if any expression in the map could not be flattened (i.e., semi-affine is
/// not yet handled).  For all affine expressions that share the same operands
/// (like those of an affine map), this method should be used instead of
/// repeatedly calling getFlattenedAffineExpr since local variables added to
/// deal with div's and mod's will be reused across expressions.
bool getFlattenedAffineExprs(
    AffineMap map, std::vector<SmallVector<int64_t, 8>> *flattenedExprs);
bool getFlattenedAffineExprs(
    IntegerSet set, std::vector<SmallVector<int64_t, 8>> *flattenedExprs);

namespace detail {
template <int N> void bindDims(MLIRContext *ctx) {}

+0 −63
Original line number Diff line number Diff line
@@ -853,66 +853,3 @@ AffineExpr mlir::simplifyAffineExpr(AffineExpr expr, unsigned numDims,

  return simplifiedExpr;
}

// Flattens the expressions in map. Returns true on success or false
// if 'expr' was unable to be flattened (i.e., semi-affine expressions not
// handled yet).
static bool
getFlattenedAffineExprs(ArrayRef<AffineExpr> exprs, unsigned numDims,
                        unsigned numSymbols,
                        std::vector<SmallVector<int64_t, 8>> *flattenedExprs) {
  if (exprs.empty()) {
    return true;
  }

  SimpleAffineExprFlattener flattener(numDims, numSymbols);
  // Use the same flattener to simplify each expression successively. This way
  // local identifiers / expressions are shared.
  for (auto expr : exprs) {
    if (!expr.isPureAffine())
      return false;

    flattener.walkPostOrder(expr);
  }

  flattenedExprs->clear();
  assert(flattener.operandExprStack.size() == exprs.size());
  flattenedExprs->assign(flattener.operandExprStack.begin(),
                         flattener.operandExprStack.end());

  return true;
}

// Flattens 'expr' into 'flattenedExpr'. Returns true on success or false
// if 'expr' was unable to be flattened (semi-affine expressions not handled
// yet).
bool mlir::getFlattenedAffineExpr(AffineExpr expr, unsigned numDims,
                                  unsigned numSymbols,
                                  SmallVectorImpl<int64_t> *flattenedExpr) {
  std::vector<SmallVector<int64_t, 8>> flattenedExprs;
  bool ret =
      ::getFlattenedAffineExprs({expr}, numDims, numSymbols, &flattenedExprs);
  *flattenedExpr = flattenedExprs[0];
  return ret;
}

/// Flattens the expressions in map. Returns true on success or false
/// if 'expr' was unable to be flattened (i.e., semi-affine expressions not
/// handled yet).
bool mlir::getFlattenedAffineExprs(
    AffineMap map, std::vector<SmallVector<int64_t, 8>> *flattenedExprs) {
  if (map.getNumResults() == 0) {
    return true;
  }
  return ::getFlattenedAffineExprs(map.getResults(), map.getNumDims(),
                                   map.getNumSymbols(), flattenedExprs);
}

bool mlir::getFlattenedAffineExprs(
    IntegerSet set, std::vector<SmallVector<int64_t, 8>> *flattenedExprs) {
  if (set.getNumConstraints() == 0) {
    return true;
  }
  return ::getFlattenedAffineExprs(set.getConstraints(), set.getNumDims(),
                                   set.getNumSymbols(), flattenedExprs);
}