15 #ifndef MLIR_DIALECT_SDBM_SDBMEXPR_H 16 #define MLIR_DIALECT_SDBM_SDBMEXPR_H 19 #include "llvm/ADT/DenseMapInfo.h" 29 struct SDBMExprStorage;
30 struct SDBMBinaryExprStorage;
31 struct SDBMDiffExprStorage;
32 struct SDBMTermExprStorage;
33 struct SDBMConstantExprStorage;
34 struct SDBMNegExprStorage;
105 explicit operator bool()
const {
return impl !=
nullptr; }
106 bool operator!()
const {
return !
static_cast<bool>(*this); }
112 void print(raw_ostream &os)
const;
116 template <
typename U>
bool isa()
const {
return U::isClassFor(*
this); }
120 return U(const_cast<SDBMExpr *>(
this)->impl);
122 template <
typename U> U
cast()
const {
123 assert(isa<U>() &&
"cast to incorrect subtype");
124 return U(const_cast<SDBMExpr *>(
this)->impl);
169 int64_t getValue()
const;
199 using SDBMVaryingExpr::SDBMVaryingExpr;
206 int64_t getConstant();
223 using SDBMDirectExpr::SDBMDirectExpr;
236 using SDBMDirectExpr::SDBMDirectExpr;
258 using SDBMVaryingExpr::SDBMVaryingExpr;
277 using SDBMTermExpr::SDBMTermExpr;
296 using SDBMTermExpr::SDBMTermExpr;
303 unsigned getPosition()
const;
311 using SDBMInputExpr::SDBMInputExpr;
327 using SDBMInputExpr::SDBMInputExpr;
343 using SDBMVaryingExpr::SDBMVaryingExpr;
357 template <
typename Derived,
typename Result =
void>
class SDBMVisitor {
361 auto *derived =
static_cast<Derived *
>(
this);
374 llvm_unreachable(
"unsupported SDBM expression kind");
399 auto *derived =
static_cast<Derived *
>(
this);
401 return derived->visitSum(sum);
409 auto *derived =
static_cast<Derived *
>(
this);
420 auto *derived =
static_cast<Derived *
>(
this);
431 auto *derived =
static_cast<Derived *
>(
this);
433 return derived->visitDirect(var);
435 return derived->visitNeg(neg);
437 return derived->visitDiff(diff);
439 llvm_unreachable(
"unhandled subtype of varying SDBM expression");
446 walk<isPreorder>(sumExpr.getLHS());
447 walk<isPreorder>(sumExpr.getRHS());
449 walk<isPreorder>(diffExpr.getLHS());
450 walk<isPreorder>(diffExpr.getRHS());
452 walk<isPreorder>(stripeExpr.getLHS());
453 walk<isPreorder>(stripeExpr.getStripeFactor());
455 walk<isPreorder>(negExpr.getVar());
465 namespace ops_assertions {
503 return mlir::SDBMExpr(static_cast<mlir::SDBMExpr::ImplType *>(pointer));
507 return mlir::SDBMExpr(static_cast<mlir::SDBMExpr::ImplType *>(pointer));
522 static_cast<mlir::SDBMExpr::ImplType *>(pointer));
527 static_cast<mlir::SDBMExpr::ImplType *>(pointer));
560 static_cast<mlir::SDBMExpr::ImplType *>(pointer));
565 static_cast<mlir::SDBMExpr::ImplType *>(pointer));
576 #endif // MLIR_DIALECT_SDBM_SDBMEXPR_H Definition: InferTypeOpInterface.cpp:20
SDBMDialect * getDialect() const
Returns the SDBM dialect instance.
Definition: SDBMExpr.cpp:148
void visitDim(SDBMDimExpr)
Definition: SDBMExpr.h:390
Result visit(SDBMExpr expr)
Visit the given SDBM expression, dispatching to kind-specific functions.
Definition: SDBMExpr.h:360
void visitSum(SDBMSumExpr)
Default visitors do nothing.
Definition: SDBMExpr.h:387
Definition: SDBMExprDetail.h:27
Definition: PassRegistry.cpp:413
static mlir::SDBMDirectExpr getTombstoneKey()
Definition: SDBMExpr.h:524
static SDBMConstantExpr get(SDBMDialect *dialect, int64_t value)
Definition: SDBMExpr.cpp:633
SDBMExprKind getKind() const
Returns the kind of the SDBM expression.
Definition: SDBMExpr.cpp:142
bool operator==(const SDBMExpr &other) const
SDBM expressions can be compared straight-forwardly.
Definition: SDBMExpr.h:100
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:241
Definition: SDBMExpr.h:178
IntInfty operator+(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:57
void walkPreorder(SDBMExpr expr)
Definition: SDBMExpr.h:379
static bool isEqual(mlir::SDBMExpr lhs, mlir::SDBMExpr rhs)
Definition: SDBMExpr.h:512
static unsigned getHashValue(mlir::SDBMConstantExpr expr)
Definition: SDBMExpr.h:567
void walkPostorder(SDBMExpr expr)
Definition: SDBMExpr.h:383
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:317
Result visitInput(SDBMInputExpr expr)
Definition: SDBMExpr.h:419
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:183
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:208
static mlir::SDBMConstantExpr getTombstoneKey()
Definition: SDBMExpr.h:562
SDBMExprKind
Definition: SDBMExpr.h:26
void visitSymbol(SDBMSymbolExpr)
Definition: SDBMExpr.h:391
SDBMExpr stripe(SDBMExpr expr, int64_t factor)
Definition: SDBMExpr.h:491
void visitNeg(SDBMNegExpr)
Definition: SDBMExpr.h:392
U cast() const
Definition: SDBMExpr.h:122
SDBM constant expression, wraps a 64-bit integer.
Definition: SDBMExpr.h:155
Definition: SDBMExprDetail.h:57
static bool isEqual(mlir::SDBMDirectExpr lhs, mlir::SDBMDirectExpr rhs)
Definition: SDBMExpr.h:532
static mlir::SDBMTermExpr getTombstoneKey()
Definition: SDBMExpr.h:543
Definition: SDBMExprDetail.h:36
bool operator!() const
Definition: SDBMExpr.h:106
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:333
SDBMExpr()
Definition: SDBMExpr.h:91
static mlir::SDBMExpr getTombstoneKey()
Definition: SDBMExpr.h:505
Definition: SDBMExpr.h:324
static mlir::SDBMDirectExpr getEmptyKey()
Definition: SDBMExpr.h:519
Definition: SDBMExprDetail.h:110
Definition: AffineExpr.h:66
Result visitVarying(SDBMVaryingExpr expr)
Definition: SDBMExpr.h:430
SDBMExpr(ImplType *expr)
Definition: SDBMExpr.h:92
Definition: SDBMExpr.h:274
static bool isEqual(mlir::SDBMConstantExpr lhs, mlir::SDBMConstantExpr rhs)
Definition: SDBMExpr.h:570
Definition: SDBMExpr.h:308
ImplType * impl
Definition: SDBMExpr.h:151
static bool isEqual(mlir::SDBMTermExpr lhs, mlir::SDBMTermExpr rhs)
Definition: SDBMExpr.h:550
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:348
static unsigned getHashValue(mlir::SDBMExpr expr)
Definition: SDBMExpr.h:509
Result visitTerm(SDBMTermExpr expr)
Definition: SDBMExpr.h:408
void visitStripe(SDBMStripeExpr)
Definition: SDBMExpr.h:389
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
Definition: AffineExpr.h:201
bool operator!=(const SDBMExpr &other) const
Definition: SDBMExpr.h:101
Definition: SDBMExpr.h:357
Definition: SDBMExpr.h:340
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:279
SDBM sum expression. LHS is a term expression and RHS is a constant.
Definition: SDBMExpr.h:233
Definition: SDBMExpr.h:197
Definition: SDBMExprDetail.h:94
static mlir::SDBMConstantExpr getEmptyKey()
Definition: SDBMExpr.h:557
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:225
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
static mlir::SDBMTermExpr getEmptyKey()
Definition: SDBMExpr.h:539
static unsigned getHashValue(mlir::SDBMDirectExpr expr)
Definition: SDBMExpr.h:529
Definition: SDBMDialect.h:18
void visitConstant(SDBMConstantExpr)
Definition: SDBMExpr.h:393
Definition: SDBMExprDetail.h:78
bool isa() const
LLVM-style casts.
Definition: SDBMExpr.h:116
Result visitDirect(SDBMDirectExpr expr)
Definition: SDBMExpr.h:398
void visitDiff(SDBMDiffExpr)
Definition: SDBMExpr.h:388
static mlir::SDBMExpr getEmptyKey()
Definition: SDBMExpr.h:501
U dyn_cast() const
Definition: SDBMExpr.h:117
Definition: SDBMExpr.h:255
static unsigned getHashValue(mlir::SDBMTermExpr expr)
Definition: SDBMExpr.h:547
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:263
void walk(SDBMExpr expr)
Definition: SDBMExpr.h:442
static bool isClassFor(const SDBMExpr &expr)
Definition: SDBMExpr.h:165
Definition: SDBMExpr.h:221
::llvm::hash_code hash_value() const
Support for LLVM hashing.
Definition: SDBMExpr.h:128
Definition: SDBMExpr.h:88