14 #ifndef MLIR_IR_AFFINE_EXPR_H 15 #define MLIR_IR_AFFINE_EXPR_H 18 #include "llvm/ADT/DenseMapInfo.h" 19 #include "llvm/Support/Casting.h" 20 #include <type_traits> 30 struct AffineExprStorage;
31 struct AffineBinaryOpExprStorage;
32 struct AffineDimExprStorage;
33 struct AffineSymbolExprStorage;
34 struct AffineConstantExprStorage;
72 : expr(const_cast<
ImplType *>(expr)) {}
83 bool operator!=(int64_t v)
const {
return !(*
this == v); }
84 explicit operator bool()
const {
return expr; }
88 template <
typename U>
bool isa()
const;
89 template <
typename U> U dyn_cast()
const;
90 template <
typename U> U dyn_cast_or_null()
const;
91 template <
typename U> U cast()
const;
98 void print(raw_ostream &os)
const;
103 bool isSymbolicOrConstant()
const;
107 bool isPureAffine()
const;
111 int64_t getLargestKnownDivisor()
const;
114 bool isMultipleOf(int64_t factor)
const;
117 bool isFunctionOfDim(
unsigned position)
const;
120 void walk(std::function<
void(
AffineExpr)> callback)
const;
181 unsigned getPosition()
const;
189 unsigned getPosition()
const;
197 int64_t getValue()
const;
208 return expr * (-1) + val;
230 if (std::is_same<U, AffineBinaryOpExpr>::value)
232 if (std::is_same<U, AffineDimExpr>::value)
234 if (std::is_same<U, AffineSymbolExpr>::value)
236 if (std::is_same<U, AffineConstantExpr>::value)
245 return (!*
this || !isa<U>()) ? U(
nullptr) : U(expr);
257 unsigned numSymbols);
282 template <
int N,
typename AffineExprTy,
typename... AffineExprTy2>
285 bindDims<N + 1, AffineExprTy2 &...>(ctx, exprs...);
291 template <
typename... AffineExprTy>
293 detail::bindDims<0>(ctx, exprs...);
304 return mlir::AffineExpr(static_cast<mlir::AffineExpr::ImplType *>(pointer));
308 return mlir::AffineExpr(static_cast<mlir::AffineExpr::ImplType *>(pointer));
320 #endif // MLIR_IR_AFFINE_EXPR_H Definition: AffineExpr.h:168
Definition: InferTypeOpInterface.cpp:20
AffineExpr & operator=(AffineExpr other)
Definition: AffineExpr.h:75
LogicalResult getFlattenedAffineExprs(AffineMap map, std::vector< SmallVector< int64_t, 8 >> *flattenedExprs, FlatAffineConstraints *cst=nullptr)
Definition: AffineStructures.cpp:115
Base storage class appearing in an affine expression.
Definition: AffineExprDetail.h:28
void bindDims(MLIRContext *ctx)
Definition: AffineExpr.h:280
Definition: PassRegistry.cpp:413
AffineExpr getAffineConstantExpr(int64_t constant, MLIRContext *context)
Definition: AffineExpr.cpp:277
ValueHandle operator%(ValueHandle lhs, ValueHandle rhs)
Definition: Builders.cpp:390
Definition: Attributes.h:129
static mlir::AffineExpr getEmptyKey()
Definition: AffineExpr.h:302
bool operator==(AffineExpr other) const
Definition: AffineExpr.h:80
IntInfty operator+(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:57
A binary operation appearing in an affine expression.
Definition: AffineExprDetail.h:33
ImplType * expr
Definition: AffineExpr.h:159
Definition: Parser.cpp:2392
An integer constant appearing in affine expression.
Definition: AffineExpr.h:193
AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols)
Simplify the affine expression by flattening it and reconstructing it.
Definition: AffineExpr.cpp:839
U dyn_cast() const
Definition: AffineExpr.h:239
int64_t floorDiv(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:31
static bool isEqual(mlir::AffineExpr LHS, mlir::AffineExpr RHS)
Definition: AffineExpr.h:313
AffineExpr(const ImplType *expr)
Definition: AffineExpr.h:71
LogicalResult getFlattenedAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, SmallVectorImpl< int64_t > *flattenedExpr, FlatAffineConstraints *cst=nullptr)
Definition: AffineStructures.cpp:102
AffineExpr getAffineSymbolExpr(unsigned position, MLIRContext *context)
Definition: AffineExpr.cpp:262
int64_t ceilDiv(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:23
auto map(Fn fun, IterType begin, IterType end) -> SmallVector< typename std::result_of< Fn(decltype(*begin))>::type, 8 >
Map with iterators.
Definition: Functional.h:28
Definition: AffineExpr.h:66
Definition: Parser.cpp:2393
Definition: AffineMap.h:37
U cast() const
Definition: AffineExpr.h:247
ValueBuilder< mlir::LLVM::ConstantOp > constant
Definition: LinalgToLLVM.cpp:56
U dyn_cast_or_null() const
Definition: AffineExpr.h:244
AffineExpr getAffineDimExpr(unsigned position, MLIRContext *context)
These free functions allow clients of the API to not use classes in detail.
Definition: AffineExpr.cpp:252
AffineExpr getAffineBinaryOpExpr(AffineExprKind kind, AffineExpr lhs, AffineExpr rhs)
Definition: AffineExpr.cpp:45
static unsigned getHashValue(mlir::AffineExpr val)
Definition: AffineExpr.h:310
bool operator==(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:90
bool isa() const
Definition: AffineExpr.h:229
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
Definition: AffineExpr.h:201
bool operator!=(int64_t v) const
Definition: AffineExpr.h:83
A dimensional or symbolic identifier appearing in an affine expression.
Definition: AffineExprDetail.h:54
AffineExpr()
Definition: AffineExpr.h:70
A dimensional identifier appearing in an affine expression.
Definition: AffineExpr.h:177
AffineExpr(const AffineExpr &other)
Definition: AffineExpr.h:74
AffineExprKind
Definition: AffineExpr.h:38
Definition: Parser.cpp:2381
Definition: MLIRContext.h:34
void print(OpAsmPrinter &p, AffineIfOp op)
Definition: AffineOps.cpp:1671
AffineExpr operator-(int64_t val, AffineExpr expr)
Definition: AffineExpr.h:207
An integer constant appearing in affine expression.
Definition: AffineExprDetail.h:71
Definition: Parser.cpp:2391
AffineExpr toAffineExpr(ArrayRef< int64_t > eq, unsigned numDims, unsigned numSymbols, ArrayRef< AffineExpr > localExprs, MLIRContext *context)
Definition: AffineExpr.cpp:594
raw_ostream & operator<<(raw_ostream &os, SubViewOp::Range &range)
Definition: Ops.cpp:2759
AffineExpr operator*(int64_t val, AffineExpr expr)
Definition: AffineExpr.h:206
Definition: Parser.cpp:2390
static mlir::AffineExpr getTombstoneKey()
Definition: AffineExpr.h:306
bool operator!=(AffineExpr other) const
Definition: AffineExpr.h:81
Definition: Attributes.h:135
bool operator!() const
Definition: AffineExpr.h:86
A symbolic identifier appearing in an affine expression.
Definition: AffineExpr.h:185
Definition: IntegerSet.h:42