Lines Matching +defs:use +defs:region +defs:p
45 /// `region` or is an argument of `region`. A value of index type defined at the
46 /// top level of a `AffineScope` region is always a valid symbol for all
47 /// uses in that region.
48 bool mlir::affine::isTopLevelValue(Value value, Region *region) {
50 return arg.getParentRegion() == region;
51 return value.getDefiningOp()->getParentRegion() == region;
55 /// region remains legal if the operation that uses it is inlined into `dest`
72 // inlining is a valid dimension in the new region.
76 // If it's a top-level value because it's defined in the region,
155 /// Returns true if the given region 'src' can be inlined into the region
157 /// 'wouldBeCloned' is set if the region is cloned into its new location
182 // Assuming the inlined region is valid, we only need to check if the
203 /// dialect, can be inlined into the given region, false otherwise.
204 bool isLegalToInline(Operation *op, Region *region, bool wouldBeCloned,
206 // Always allow inlining affine operations into a region that is marked as
210 Operation *parentOp = region->getParentOp();
245 /// op with trait `AffineScope`. If the value is defined in an unlinked region,
251 // region has not yet been attached to an Op, at which point the parent Op
261 /// Returns the closest region enclosing `op` that is held by an operation with
262 /// trait `AffineScope`; `nullptr` if there is no such region.
298 bool mlir::affine::isValidDim(Value value, Region *region) {
304 if (isValidSymbol(value, region))
317 return applyOp.isValidDim(region);
327 /// for `region`.
330 Region *region) {
344 region);
347 /// Returns true if the result of the dim op is a valid symbol for `region`.
348 static bool isDimOpValidSymbol(ShapedDimOpInterface dimOp, Region *region) {
380 [&](auto op) { return isMemRefSizeValidSymbol(op, i, region); })
384 // A value can be used as a symbol (at all its use sites) iff it meets one of
410 /// A value can be used as a symbol for `region` iff it meets one of the
417 /// *) It is defined at the top level of 'region' or is its argument.
418 /// *) It dominates `region`'s parent op.
419 /// If `region` is null, conservatively assume the symbol definition scope does
421 /// the surrounding region structure, i.e. the first three cases above.
422 bool mlir::affine::isValidSymbol(Value value, Region *region) {
428 if (region && ::isTopLevelValue(value, region))
434 // dominates region's parent op.
435 Operation *regionOp = region ? region->getParentOp() : nullptr;
437 if (auto *parentOpRegion = region->getParentOp()->getParentRegion())
449 return affine::isValidSymbol(operand, region);
456 return isDimOpValidSymbol(dimOp, region);
458 // Check for values dominating `region`'s parent op.
459 Operation *regionOp = region ? region->getParentOp() : nullptr;
461 if (auto *parentRegion = region->getParentOp()->getParentRegion())
469 // `region` provides the polyhedral symbol scope. Returns false otherwise.
470 static bool isValidAffineIndexOperand(Value value, Region *region) {
471 return isValidDim(value, region) || isValidSymbol(value, region);
551 void AffineApplyOp::print(OpAsmPrinter &p) {
552 p << " " << getMapAttr();
554 getAffineMap().getNumDims(), p);
555 p.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"map"});
582 // its operands are valid dimension ids with the parent operation of `region`
584 bool AffineApplyOp::isValidDim(Region *region) {
586 [&](Value op) { return ::isValidDim(op, region); });
596 // The result of the affine apply operation can be used as a symbol in `region`
597 // if all its operands are symbols in `region`.
598 bool AffineApplyOp::isValidSymbol(Region *region) {
600 return affine::isValidSymbol(operand, region);
632 // We now make use of operands for the case `e` is a dim expression.
644 // We don't need to use mlir::getLargestKnownDivisorOfValue since the other
889 /// Simplify the expressions in `map` while making use of lower or upper bounds
1568 void AffineDmaStartOp::print(OpAsmPrinter &p) {
1569 p << " " << getSrcMemRef() << '[';
1570 p.printAffineMapOfSSAIds(getSrcMapAttr(), getSrcIndices());
1571 p << "], " << getDstMemRef() << '[';
1572 p.printAffineMapOfSSAIds(getDstMapAttr(), getDstIndices());
1573 p << "], " << getTagMemRef() << '[';
1574 p.printAffineMapOfSSAIds(getTagMapAttr(), getTagIndices());
1575 p << "], " << getNumElements();
1577 p << ", " << getStride();
1578 p << ", " << getNumElementsPerStride();
1580 p << " : " << getSrcMemRefType() << ", " << getDstMemRefType() << ", "
1738 void AffineDmaWaitOp::print(OpAsmPrinter &p) {
1739 p << " " << getTagMemRef() << '[';
1741 p.printAffineMapOfSSAIds(getTagMapAttr(), operands);
1742 p << "], ";
1743 p.printOperand(getNumElements());
1744 p << " : " << getTagMemRef().getType();
1855 // Create a region and a block for the body. The argument of the region is
1925 OpAsmParser &p) {
1929 failed(p.parseOptionalKeyword(isLower ? "max" : "min"));
1931 auto &builder = p.getBuilder();
1938 if (p.parseOperandList(boundOpInfos))
1944 return p.emitError(p.getNameLoc(),
1948 // Currently it is 'use of value ... expects different type than prior uses'
1949 if (p.resolveOperand(boundOpInfos.front(), builder.getIndexType(),
1962 SMLoc attrLoc = p.getCurrentLocation();
1965 if (p.parseAttribute(boundAttr, builder.getIndexType(), boundAttrStrName,
1973 if (parseDimAndSymbolList(p, result.operands, numDims))
1978 return p.emitError(
1979 p.getNameLoc(),
1985 return p.emitError(
1986 p.getNameLoc(),
1993 return p.emitError(attrLoc, "lower loop bound affine map with "
1996 return p.emitError(attrLoc, "upper loop bound affine map with multiple "
2011 return p.emitError(
2012 p.getNameLoc(),
2084 // Parse the body region.
2101 const char *prefix, OpAsmPrinter &p) {
2116 p << constExpr.getValue();
2125 p.printOperand(*boundOperands.begin());
2131 p << prefix << ' ';
2135 p << boundMap;
2137 map.getNumDims(), p);
2152 void AffineForOp::print(OpAsmPrinter &p) {
2153 p << ' ';
2154 p.printRegionArgument(getBody()->getArgument(0), /*argAttrs=*/{},
2156 p << " = ";
2157 printBound(getLowerBoundMapAttr(), getLowerBoundOperands(), "max", p);
2158 p << " to ";
2159 printBound(getUpperBoundMapAttr(), getUpperBoundOperands(), "min", p);
2162 p << " step " << getStepAsInt();
2166 p << " iter_args(";
2170 llvm::interleaveComma(llvm::zip(regionArgs, operands), p, [&](auto it) {
2171 p << std::get<0>(it) << " = " << std::get<1>(it);
2173 p << ") -> (" << getResultTypes() << ")";
2177 p << ' ';
2178 p.printRegion(getRegion(), /*printEntryBlockArgs=*/false,
2180 p.printOptionalAttrDict(
2337 assert((point.isParent() || point == getRegion()) && "invalid region point");
2346 assert((point.isParent() || point == getRegion()) && "expected loop region");
2532 [&](OpOperand &use) {
2533 Operation *user = use.getOwner();
2737 // The absence, or equivalently, the emptiness of the else region need not
2739 // operation is returning results, it always has a non-empty else region.
2741 // If the else region is absent, or equivalently, empty, remove the
2777 // `else` region is valid.
2782 // If the "else" region is empty, branch bach into parent.
2792 // If the predecessor is the `else`/`then` region, then branching into parent
2849 // Parse the 'then' region.
2855 // If we find an 'else' keyword then parse the 'else' region.
2870 void AffineIfOp::print(OpAsmPrinter &p) {
2873 p << " " << conditionAttr;
2875 conditionAttr.getValue().getNumDims(), p);
2876 p.printOptionalArrowTypeList(getResultTypes());
2877 p << ' ';
2878 p.printRegion(getThenRegion(), /*printEntryBlockArgs=*/false,
2884 p << " else ";
2885 p.printRegion(elseRegion,
2891 p.printOptionalAttrDict((*this)->getAttrs(),
3034 void AffineLoadOp::print(OpAsmPrinter &p) {
3035 p << " " << getMemRef() << '[';
3038 p.printAffineMapOfSSAIds(mapAttr, getMapOperands());
3039 p << ']';
3040 p.printOptionalAttrDict((*this)->getAttrs(),
3042 p << " : " << getMemRefType();
3172 void AffineStoreOp::print(OpAsmPrinter &p) {
3173 p << " " << getValueToStore();
3174 p << ", " << getMemRef() << '[';
3177 p.printAffineMapOfSSAIds(mapAttr, getMapOperands());
3178 p << ']';
3179 p.printOptionalAttrDict((*this)->getAttrs(),
3181 p << " : " << getMemRefType();
3230 static void printAffineMinMaxOp(OpAsmPrinter &p, T op) {
3231 p << ' ' << op->getAttr(T::getMapAttrStrName());
3234 p << '(' << operands.take_front(numDims) << ')';
3237 p << '[' << operands.drop_front(numDims) << ']';
3238 p.printOptionalAttrDict(op->getAttrs(),
3536 void AffineMinOp::print(OpAsmPrinter &p) { printAffineMinMaxOp(p, *this); }
3564 void AffineMaxOp::print(OpAsmPrinter &p) { printAffineMinMaxOp(p, *this); }
3620 void AffinePrefetchOp::print(OpAsmPrinter &p) {
3621 p << " " << getMemref() << '[';
3625 p.printAffineMapOfSSAIds(mapAttr, getMapOperands());
3626 p << ']' << ", " << (getIsWrite() ? "write" : "read") << ", "
3629 p.printOptionalAttrDict(
3633 p << " : " << getMemRefType();
3759 // Create a region and a block for the body.
3910 return emitOpError() << "the number of region arguments ("
4000 static void printMinMaxBound(OpAsmPrinter &p, AffineMapAttr mapAttr,
4010 p << ", ";
4014 p.printAffineExprOfSSAIds(map.getResult(start), dimOperands, symOperands);
4017 p << keyword << '(';
4019 p.printAffineMapOfSSAIds(AffineMapAttr::get(submap), operands);
4020 p << ')';
4026 void AffineParallelOp::print(OpAsmPrinter &p) {
4027 p << " (" << getBody()->getArguments() << ") = (";
4028 printMinMaxBound(p, getLowerBoundsMapAttr(), getLowerBoundsGroupsAttr(),
4030 p << ") to (";
4031 printMinMaxBound(p, getUpperBoundsMapAttr(), getUpperBoundsGroupsAttr(),
4033 p << ')';
4037 p << " step (";
4038 llvm::interleaveComma(steps, p);
4039 p << ')';
4042 p << " reduce (";
4043 llvm::interleaveComma(getReductions(), p, [&](auto &attr) {
4046 p << "\"" << arith::stringifyAtomicRMWKind(sym) << "\"";
4048 p << ") -> (" << getResultTypes() << ")";
4051 p << ' ';
4052 p.printRegion(getRegion(), /*printEntryBlockArgs=*/false,
4054 p.printOptionalAttrDict(
4213 // `to` parallel-bound steps? region attr-dict?
4390 void AffineVectorLoadOp::print(OpAsmPrinter &p) {
4391 p << " " << getMemRef() << '[';
4394 p.printAffineMapOfSSAIds(mapAttr, getMapOperands());
4395 p << ']';
4396 p.printOptionalAttrDict((*this)->getAttrs(),
4398 p << " : " << getMemRefType() << ", " << getType();
4481 void AffineVectorStoreOp::print(OpAsmPrinter &p) {
4482 p << " " << getValueToStore();
4483 p << ", " << getMemRef() << '[';
4486 p.printAffineMapOfSSAIds(mapAttr, getMapOperands());
4487 p << ']';
4488 p.printOptionalAttrDict((*this)->getAttrs(),
4490 p << " : " << getMemRefType() << ", " << getValueToStore().getType();
4755 // Note: we use the full basis so we don't lose outer bounds later.
5207 // the new linearization operation, since the new operation might use
5228 // We use the slice from the linearize's basis above because of the