#include <cmath>
#include <cstdint>
#include <limits>
#include <utility>
#include "AffineExprDetail.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/Support/TypeID.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/MathExtras.h"
#include <numeric>
#include <optional>
usingnamespacemlir;
usingnamespacemlir::detail;
divideCeilSigned;
divideFloorSigned;
divideSignedWouldOverflow;
mod;
MLIRContext *AffineExpr::getContext() const { … }
AffineExprKind AffineExpr::getKind() const { … }
template <typename WalkRetTy>
WalkRetTy mlir::AffineExpr::walk(AffineExpr e,
function_ref<WalkRetTy(AffineExpr)> callback) { … }
template void mlir::AffineExpr::walk(AffineExpr e,
function_ref<void(AffineExpr)> callback);
template WalkResult
mlir::AffineExpr::walk(AffineExpr e,
function_ref<WalkResult(AffineExpr)> callback);
AffineExpr mlir::getAffineBinaryOpExpr(AffineExprKind kind, AffineExpr lhs,
AffineExpr rhs) { … }
AffineExpr
AffineExpr::replaceDimsAndSymbols(ArrayRef<AffineExpr> dimReplacements,
ArrayRef<AffineExpr> symReplacements) const { … }
AffineExpr AffineExpr::replaceDims(ArrayRef<AffineExpr> dimReplacements) const { … }
AffineExpr
AffineExpr::replaceSymbols(ArrayRef<AffineExpr> symReplacements) const { … }
AffineExpr AffineExpr::shiftDims(unsigned numDims, unsigned shift,
unsigned offset) const { … }
AffineExpr AffineExpr::shiftSymbols(unsigned numSymbols, unsigned shift,
unsigned offset) const { … }
AffineExpr
AffineExpr::replace(const DenseMap<AffineExpr, AffineExpr> &map) const { … }
AffineExpr AffineExpr::replace(AffineExpr expr, AffineExpr replacement) const { … }
bool AffineExpr::isSymbolicOrConstant() const { … }
bool AffineExpr::isPureAffine() const { … }
int64_t AffineExpr::getLargestKnownDivisor() const { … }
bool AffineExpr::isMultipleOf(int64_t factor) const { … }
bool AffineExpr::isFunctionOfDim(unsigned position) const { … }
bool AffineExpr::isFunctionOfSymbol(unsigned position) const { … }
AffineBinaryOpExpr::AffineBinaryOpExpr(AffineExpr::ImplType *ptr)
: … { … }
AffineExpr AffineBinaryOpExpr::getLHS() const { … }
AffineExpr AffineBinaryOpExpr::getRHS() const { … }
AffineDimExpr::AffineDimExpr(AffineExpr::ImplType *ptr) : … { … }
unsigned AffineDimExpr::getPosition() const { … }
static bool isDivisibleBySymbol(AffineExpr expr, unsigned symbolPos,
AffineExprKind opKind) { … }
static AffineExpr symbolicDivide(AffineExpr expr, unsigned symbolPos,
AffineExprKind opKind) { … }
static void getSummandExprs(AffineExpr expr, SmallVector<AffineExpr> &result) { … }
static bool isNegatedAffineExpr(AffineExpr candidate, AffineExpr &expr) { … }
static bool isModOfModSubtraction(AffineExpr lhs, AffineExpr rhs,
unsigned numDims, unsigned numSymbols) { … }
static AffineExpr simplifySemiAffine(AffineExpr expr, unsigned numDims,
unsigned numSymbols) { … }
static AffineExpr getAffineDimOrSymbol(AffineExprKind kind, unsigned position,
MLIRContext *context) { … }
AffineExpr mlir::getAffineDimExpr(unsigned position, MLIRContext *context) { … }
AffineSymbolExpr::AffineSymbolExpr(AffineExpr::ImplType *ptr)
: … { … }
unsigned AffineSymbolExpr::getPosition() const { … }
AffineExpr mlir::getAffineSymbolExpr(unsigned position, MLIRContext *context) { … }
AffineConstantExpr::AffineConstantExpr(AffineExpr::ImplType *ptr)
: … { … }
int64_t AffineConstantExpr::getValue() const { … }
bool AffineExpr::operator==(int64_t v) const { … }
AffineExpr mlir::getAffineConstantExpr(int64_t constant, MLIRContext *context) { … }
SmallVector<AffineExpr>
mlir::getAffineConstantExprs(ArrayRef<int64_t> constants,
MLIRContext *context) { … }
static AffineExpr simplifyAdd(AffineExpr lhs, AffineExpr rhs) { … }
AffineExpr AffineExpr::operator+(int64_t v) const { … }
AffineExpr AffineExpr::operator+(AffineExpr other) const { … }
static AffineExpr simplifyMul(AffineExpr lhs, AffineExpr rhs) { … }
AffineExpr AffineExpr::operator*(int64_t v) const { … }
AffineExpr AffineExpr::operator*(AffineExpr other) const { … }
AffineExpr AffineExpr::operator-() const { … }
AffineExpr AffineExpr::operator-(int64_t v) const { … }
AffineExpr AffineExpr::operator-(AffineExpr other) const { … }
static AffineExpr simplifyFloorDiv(AffineExpr lhs, AffineExpr rhs) { … }
AffineExpr AffineExpr::floorDiv(uint64_t v) const { … }
AffineExpr AffineExpr::floorDiv(AffineExpr other) const { … }
static AffineExpr simplifyCeilDiv(AffineExpr lhs, AffineExpr rhs) { … }
AffineExpr AffineExpr::ceilDiv(uint64_t v) const { … }
AffineExpr AffineExpr::ceilDiv(AffineExpr other) const { … }
static AffineExpr simplifyMod(AffineExpr lhs, AffineExpr rhs) { … }
AffineExpr AffineExpr::operator%(uint64_t v) const { … }
AffineExpr AffineExpr::operator%(AffineExpr other) const { … }
AffineExpr AffineExpr::compose(AffineMap map) const { … }
raw_ostream &mlir::operator<<(raw_ostream &os, AffineExpr expr) { … }
AffineExpr mlir::getAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
unsigned numDims,
unsigned numSymbols,
ArrayRef<AffineExpr> localExprs,
MLIRContext *context) { … }
static AffineExpr getSemiAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
unsigned numDims,
unsigned numSymbols,
ArrayRef<AffineExpr> localExprs,
MLIRContext *context) { … }
SimpleAffineExprFlattener::SimpleAffineExprFlattener(unsigned numDims,
unsigned numSymbols)
: … { … }
LogicalResult SimpleAffineExprFlattener::visitMulExpr(AffineBinaryOpExpr expr) { … }
LogicalResult SimpleAffineExprFlattener::visitAddExpr(AffineBinaryOpExpr expr) { … }
LogicalResult SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) { … }
LogicalResult
SimpleAffineExprFlattener::visitCeilDivExpr(AffineBinaryOpExpr expr) { … }
LogicalResult
SimpleAffineExprFlattener::visitFloorDivExpr(AffineBinaryOpExpr expr) { … }
LogicalResult SimpleAffineExprFlattener::visitDimExpr(AffineDimExpr expr) { … }
LogicalResult
SimpleAffineExprFlattener::visitSymbolExpr(AffineSymbolExpr expr) { … }
LogicalResult
SimpleAffineExprFlattener::visitConstantExpr(AffineConstantExpr expr) { … }
LogicalResult SimpleAffineExprFlattener::addLocalVariableSemiAffine(
ArrayRef<int64_t> lhs, ArrayRef<int64_t> rhs, AffineExpr localExpr,
SmallVectorImpl<int64_t> &result, unsigned long resultSize) { … }
LogicalResult SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
bool isCeil) { … }
void SimpleAffineExprFlattener::addLocalFloorDivId(ArrayRef<int64_t> dividend,
int64_t divisor,
AffineExpr localExpr) { … }
LogicalResult SimpleAffineExprFlattener::addLocalIdSemiAffine(
ArrayRef<int64_t> lhs, ArrayRef<int64_t> rhs, AffineExpr localExpr) { … }
int SimpleAffineExprFlattener::findLocalId(AffineExpr localExpr) { … }
AffineExpr mlir::simplifyAffineExpr(AffineExpr expr, unsigned numDims,
unsigned numSymbols) { … }
std::optional<int64_t> mlir::getBoundForAffineExpr(
AffineExpr expr, unsigned numDims, unsigned numSymbols,
ArrayRef<std::optional<int64_t>> constLowerBounds,
ArrayRef<std::optional<int64_t>> constUpperBounds, bool isUpper) { … }