forked from OSchip/llvm-project
Rename isSymbolic to isSymbolicOrConstant to avoid confusion.
PiperOrigin-RevId: 205288794
This commit is contained in:
parent
6ada91db02
commit
8bbdd04365
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
/// Returns true if this expression is made out of only symbols and
|
||||
/// constants, i.e., it does not involve dimensional identifiers.
|
||||
bool isSymbolic() const;
|
||||
bool isSymbolicOrConstant() const;
|
||||
|
||||
/// Returns true if this is a pure affine expression, i.e., multiplication,
|
||||
/// floordiv, ceildiv, and mod is only allowed w.r.t constants.
|
||||
|
|
|
@ -35,19 +35,19 @@ AffineBinaryOpExpr::AffineBinaryOpExpr(Kind kind, AffineExpr *lhs,
|
|||
break;
|
||||
case Kind::Mul:
|
||||
assert(!isa<AffineConstantExpr>(lhs));
|
||||
assert(rhs->isSymbolic());
|
||||
assert(rhs->isSymbolicOrConstant());
|
||||
// TODO (more verification)
|
||||
break;
|
||||
case Kind::FloorDiv:
|
||||
assert(rhs->isSymbolic());
|
||||
assert(rhs->isSymbolicOrConstant());
|
||||
// TODO (more verification)
|
||||
break;
|
||||
case Kind::CeilDiv:
|
||||
assert(rhs->isSymbolic());
|
||||
assert(rhs->isSymbolicOrConstant());
|
||||
// TODO (more verification)
|
||||
break;
|
||||
case Kind::Mod:
|
||||
assert(rhs->isSymbolic());
|
||||
assert(rhs->isSymbolicOrConstant());
|
||||
// TODO (more verification)
|
||||
break;
|
||||
default:
|
||||
|
@ -57,7 +57,7 @@ AffineBinaryOpExpr::AffineBinaryOpExpr(Kind kind, AffineExpr *lhs,
|
|||
|
||||
/// Returns true if this expression is made out of only symbols and
|
||||
/// constants (no dimensional identifiers).
|
||||
bool AffineExpr::isSymbolic() const {
|
||||
bool AffineExpr::isSymbolicOrConstant() const {
|
||||
switch (getKind()) {
|
||||
case Kind::Constant:
|
||||
return true;
|
||||
|
@ -73,7 +73,8 @@ bool AffineExpr::isSymbolic() const {
|
|||
case Kind::CeilDiv:
|
||||
case Kind::Mod: {
|
||||
auto expr = cast<AffineBinaryOpExpr>(this);
|
||||
return expr->getLHS()->isSymbolic() && expr->getRHS()->isSymbolic();
|
||||
return expr->getLHS()->isSymbolicOrConstant() &&
|
||||
expr->getRHS()->isSymbolicOrConstant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ AffineExpr *AffineBinaryOpExpr::simplifyAdd(AffineExpr *lhs, AffineExpr *rhs,
|
|||
if (auto *r = dyn_cast<AffineConstantExpr>(rhs))
|
||||
return AffineConstantExpr::get(l->getValue() + r->getValue(), context);
|
||||
|
||||
if (isa<AffineConstantExpr>(lhs) || (lhs->isSymbolic() && !rhs->isSymbolic()))
|
||||
if (isa<AffineConstantExpr>(lhs) ||
|
||||
(lhs->isSymbolicOrConstant() && !rhs->isSymbolicOrConstant()))
|
||||
return AffineAddExpr::get(rhs, lhs, context);
|
||||
|
||||
return nullptr;
|
||||
|
@ -63,12 +64,12 @@ AffineExpr *AffineBinaryOpExpr::simplifyMul(AffineExpr *lhs, AffineExpr *rhs,
|
|||
if (auto *r = dyn_cast<AffineConstantExpr>(rhs))
|
||||
return AffineConstantExpr::get(l->getValue() * r->getValue(), context);
|
||||
|
||||
assert(lhs->isSymbolic() || rhs->isSymbolic());
|
||||
assert(lhs->isSymbolicOrConstant() || rhs->isSymbolicOrConstant());
|
||||
|
||||
// Canonicalize the mul expression so that the constant/symbolic term is the
|
||||
// RHS. If both the lhs and rhs are symbolic, swap them if the lhs is a
|
||||
// constant. (Note that a constant is trivially symbolic).
|
||||
if (!rhs->isSymbolic() || isa<AffineConstantExpr>(lhs)) {
|
||||
if (!rhs->isSymbolicOrConstant() || isa<AffineConstantExpr>(lhs)) {
|
||||
// At least one of them has to be symbolic.
|
||||
return AffineMulExpr::get(rhs, lhs, context);
|
||||
}
|
||||
|
|
|
@ -717,28 +717,28 @@ AffineExpr *AffineMapParser::getBinaryAffineOpExpr(AffineHighPrecOp op,
|
|||
// TODO: make the error location info accurate.
|
||||
switch (op) {
|
||||
case Mul:
|
||||
if (!lhs->isSymbolic() && !rhs->isSymbolic()) {
|
||||
if (!lhs->isSymbolicOrConstant() && !rhs->isSymbolicOrConstant()) {
|
||||
emitError("non-affine expression: at least one of the multiply "
|
||||
"operands has to be either a constant or symbolic");
|
||||
return nullptr;
|
||||
}
|
||||
return builder.getMulExpr(lhs, rhs);
|
||||
case FloorDiv:
|
||||
if (!rhs->isSymbolic()) {
|
||||
if (!rhs->isSymbolicOrConstant()) {
|
||||
emitError("non-affine expression: right operand of floordiv "
|
||||
"has to be either a constant or symbolic");
|
||||
return nullptr;
|
||||
}
|
||||
return builder.getFloorDivExpr(lhs, rhs);
|
||||
case CeilDiv:
|
||||
if (!rhs->isSymbolic()) {
|
||||
if (!rhs->isSymbolicOrConstant()) {
|
||||
emitError("non-affine expression: right operand of ceildiv "
|
||||
"has to be either a constant or symbolic");
|
||||
return nullptr;
|
||||
}
|
||||
return builder.getCeilDivExpr(lhs, rhs);
|
||||
case Mod:
|
||||
if (!rhs->isSymbolic()) {
|
||||
if (!rhs->isSymbolicOrConstant()) {
|
||||
emitError("non-affine expression: right operand of mod "
|
||||
"has to be either a constant or symbolic");
|
||||
return nullptr;
|
||||
|
|
Loading…
Reference in New Issue