}
/// Returns affine map for the lower bound.
- AffineMap getLowerBoundMap() {
- return getAttr(getLowerBoundAttrName()).cast<AffineMapAttr>().getValue();
+ AffineMap getLowerBoundMap() { return getLowerBoundMapAttr().getValue(); }
+ AffineMapAttr getLowerBoundMapAttr() {
+ return getAttr(getLowerBoundAttrName()).cast<AffineMapAttr>();
}
/// Returns affine map for the upper bound. The upper bound is exclusive.
- AffineMap getUpperBoundMap() {
- return getAttr(getUpperBoundAttrName()).cast<AffineMapAttr>().getValue();
+ AffineMap getUpperBoundMap() { return getUpperBoundMapAttr().getValue(); }
+ AffineMapAttr getUpperBoundMapAttr() {
+ return getAttr(getUpperBoundAttrName()).cast<AffineMapAttr>();
}
/// Set lower bound. The new bound must have the same number of operands as
#ifndef MLIR_IR_OPIMPLEMENTATION_H
#define MLIR_IR_OPIMPLEMENTATION_H
-#include "mlir/IR/AffineMap.h"
#include "mlir/IR/OpDefinition.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/SMLoc.h"
namespace mlir {
-class AffineExpr;
-class AffineMap;
class Builder;
class Function;
virtual void printFunctionReference(Function *func) = 0;
virtual void printAttribute(Attribute attr) = 0;
virtual void printAttributeAndType(Attribute attr) = 0;
- virtual void printAffineMap(AffineMap map) = 0;
- virtual void printAffineExpr(AffineExpr expr) = 0;
/// Print a successor, and use list, of a terminator operation given the
/// terminator and the successor index.
return p;
}
-inline OpAsmPrinter &operator<<(OpAsmPrinter &p, AffineMap map) {
- p.printAffineMap(map);
- return p;
-}
-
// Support printing anything that isn't convertible to one of the above types,
// even if it isn't exactly one of them. For example, we want to print
// FunctionType with the Type& version above, not have it match this.
template <typename T, typename std::enable_if<
!std::is_convertible<T &, Value &>::value &&
!std::is_convertible<T &, Type &>::value &&
- !std::is_convertible<T &, Attribute &>::value &&
- !std::is_convertible<T &, AffineMap &>::value,
+ !std::is_convertible<T &, Attribute &>::value,
T>::type * = nullptr>
inline OpAsmPrinter &operator<<(OpAsmPrinter &p, const T &other) {
p.getStream() << other;
}
void AffineApplyOp::print(OpAsmPrinter *p) {
- auto map = getAffineMap();
- *p << "affine.apply " << map;
- printDimAndSymbolList(operand_begin(), operand_end(), map.getNumDims(), p);
+ *p << "affine.apply " << getAttr("map");
+ printDimAndSymbolList(operand_begin(), operand_end(),
+ getAffineMap().getNumDims(), p);
p->printOptionalAttrDict(getAttrs(), /*elidedAttrs=*/{"map"});
}
return false;
}
-static void printBound(AffineBound bound, const char *prefix, OpAsmPrinter *p) {
- AffineMap map = bound.getMap();
+static void printBound(AffineMapAttr boundMap,
+ Operation::operand_range boundOperands,
+ const char *prefix, OpAsmPrinter *p) {
+ AffineMap map = boundMap.getValue();
// Check if this bound should be printed using custom assembly form.
// The decision to restrict printing custom assembly form to trivial cases
// single symbol.
if (map.getNumDims() == 0 && map.getNumSymbols() == 1) {
if (auto symExpr = expr.dyn_cast<AffineSymbolExpr>()) {
- p->printOperand(bound.getOperand(0));
+ p->printOperand(*boundOperands.begin());
return;
}
}
}
// Print the map and its operands.
- p->printAffineMap(map);
- printDimAndSymbolList(bound.operand_begin(), bound.operand_end(),
+ *p << boundMap;
+ printDimAndSymbolList(boundOperands.begin(), boundOperands.end(),
map.getNumDims(), p);
}
*p << "affine.for ";
p->printOperand(getBody()->getArgument(0));
*p << " = ";
- printBound(getLowerBound(), "max", p);
+ printBound(getLowerBoundMapAttr(), getLowerBoundOperands(), "max", p);
*p << " to ";
- printBound(getUpperBound(), "min", p);
+ printBound(getUpperBoundMapAttr(), getUpperBoundOperands(), "min", p);
if (getStep() != 1)
*p << " step " << getStep();
void printAttributeAndType(Attribute attr) {
ModulePrinter::printAttributeAndType(attr);
}
- void printAffineMap(AffineMap map) {
- return ModulePrinter::printAffineMapReference(map);
- }
- void printIntegerSet(IntegerSet set) {
- return ModulePrinter::printIntegerSetReference(set);
- }
- void printAffineExpr(AffineExpr expr) {
- return ModulePrinter::printAffineExpr(expr);
- }
void printFunctionReference(Function *func) {
return ModulePrinter::printFunctionReference(func);
}