Lines Matching +defs:use +defs:region +defs:p
53 // as necessary. Required when the region has only one block.
89 /// Verifies that the first block of the given `region` is terminated by a
92 static TerminatorTy verifyAndGetTerminator(Operation *op, Region ®ion,
95 if (!region.empty() && !region.front().empty()) {
96 terminatorOperation = ®ion.front().back();
110 /// Replaces the given op with the contents of the given single-block region,
113 Region ®ion, ValueRange blockArgs = {}) {
114 assert(llvm::hasSingleElement(region) && "expected single-region block");
115 Block *block = ®ion.front();
139 // Introduce the body region and parse it.
148 void ExecuteRegionOp::print(OpAsmPrinter &p) {
149 p.printOptionalArrowTypeList(getResultTypes());
151 p << ' ';
152 p.printRegion(getRegion(),
156 p.printOptionalAttrDict((*this)->getAttrs());
161 return emitOpError("region needs to have at least one block");
163 return emitOpError("region cannot have any arguments");
277 // Otherwise, the region branches back to the parent operation.
289 "region");
290 // Pass all operands except the condition to the successor region.
300 // Condition can either lead to the after region or back to the parent op
373 << "th iter region arg and defined value";
429 /// where 'inner' values are assumed to be region arguments and 'outer' values
431 static void printInitializationList(OpAsmPrinter &p,
440 p << prefix << '(';
441 llvm::interleaveComma(llvm::zip(blocksArgs, initializers), p, [&](auto it) {
442 p << std::get<0>(it) << " = " << std::get<1>(it);
444 p << ")";
447 void ForOp::print(OpAsmPrinter &p) {
448 p << " " << getInductionVar() << " = " << getLowerBound() << " to "
451 printInitializationList(p, getRegionIterArgs(), getInitArgs(), " iter_args");
453 p << " -> (" << getInitArgs().getTypes() << ')';
454 p << ' ';
456 p << " : " << t << ' ';
457 p.printRegion(getRegion(),
460 p.printOptionalAttrDict((*this)->getAttrs());
519 // Parse the body region.
584 [&](OpOperand &use) {
585 Operation *user = use.getOwner();
612 // Both the operation itself and the region may be branching into the body or
842 // 2) The argument's corresponding outer region iterators (inputs) are yielded.
843 // 3) The iter arguments have no use and the corresponding (operation) results
844 // have no use.
847 // the ForOp region and can just be forwarded after simplifying the op inits,
862 // IRMapping for the particular use case of calling into
876 forOp.getRegionIterArgs(), // iter inside region
881 // 1) The region `iter` argument is yielded.
882 // 2) The region `iter` argument the corresponding input is yielded.
883 // 3) The region `iter` argument has no use, and the corresponding op
884 // result has no use.
1142 return emitOpError("region expects ") << numLoops << " arguments";
1178 void ForallOp::print(OpAsmPrinter &p) {
1180 p << " (" << getInductionVars();
1182 p << ") in ";
1183 printDynamicIndexList(p, op, getDynamicUpperBound(), getStaticUpperBound(),
1187 p << ") = ";
1188 printDynamicIndexList(p, op, getDynamicLowerBound(), getStaticLowerBound(),
1191 p << " to ";
1192 printDynamicIndexList(p, op, getDynamicUpperBound(), getStaticUpperBound(),
1195 p << " step ";
1196 printDynamicIndexList(p, op, getDynamicStep(), getStaticStep(),
1200 printInitializationList(p, getRegionOutArgs(), getOutputs(), " shared_outs");
1201 p << " ";
1203 p << "-> (" << getResultTypes() << ") ";
1204 p.printRegion(getRegion(),
1207 p.printOptionalAttrDict(op->getAttrs(), {getOperandSegmentSizesAttrName(),
1280 // Parse region.
1282 std::unique_ptr<Region> region = std::make_unique<Region>();
1292 if (parser.parseRegion(*region, regionArgs))
1295 // Ensure terminator and move region.
1296 ForallOp::ensureTerminator(*region, b, result.location);
1297 result.addRegion(std::move(region));
1396 // unaware of the fact that our terminator also needs a region to be
1398 void ForallOp::ensureTerminator(Region ®ion, OpBuilder &builder,
1401 ForallOp>::ensureTerminator(region, builder, loc);
1403 llvm::dyn_cast<InParallelOp>(region.front().getTerminator());
1596 // a. If it has any use.
1599 // its destination operand. For this we use
1608 // corresponding to the i-th result with at least one use.
1623 // Return early if all results of scf.forall have at least one use and being
1663 // destination in the in_parallel op. For all other bbArgs, use the
1680 // Step 6. Replace the uses of those values that either has no use or are
1879 /// Given the region at `index`, or the parent operation if `index` is None,
1886 // Both the operation itself and the region may be branching into the body or
1926 void InParallelOp::print(OpAsmPrinter &p) {
1927 p << " ";
1928 p.printRegion(getRegion(),
1931 p.printOptionalAttrDict(getOperation()->getAttrs());
1938 std::unique_ptr<Region> region = std::make_unique<Region>();
1939 if (parser.parseRegion(*region, regionOperands))
1942 if (region->empty())
1943 OpBuilder(builder.getContext()).createBlock(region.get());
1944 result.addRegion(std::move(region));
2048 // Build then region.
2055 // Build else region.
2070 // Build then region.
2076 // Build else region.
2115 // Parse the 'then' region.
2120 // If we find an 'else' keyword then parse the 'else' region.
2133 void IfOp::print(OpAsmPrinter &p) {
2136 p << " " << getCondition();
2138 p << " -> (" << getResultTypes() << ")";
2142 p << ' ';
2143 p.printRegion(getThenRegion(),
2150 p << " else ";
2151 p.printRegion(elseRegion,
2156 p.printOptionalAttrDict((*this)->getAttrs());
2161 // The `then` and the `else` region branch back to the parent operation.
2169 // Don't consider the else region if it is empty.
2184 // If the else region is empty, execution continues after the parent op.
2208 // It would be nicer to use iplist::swap, but that has no implemented
2221 // If the condition is known, then one region is known to be executed once
2226 // Non-constant condition. Each region may be executed 0 or 1 times.
2274 // an else region since the operation returns results).
2373 /// Allow the true region of an if to assume the condition is true
2404 for (OpOperand &use :
2406 if (op.getThenRegion().isAncestor(use.getOwner()->getParentRegion())) {
2413 rewriter.modifyOpInPlace(use.getOwner(),
2414 [&]() { use.set(constantTrue); });
2416 use.getOwner()->getParentRegion())) {
2423 rewriter.modifyOpInPlace(use.getOwner(),
2424 [&]() { use.set(constantFalse); });
2603 for (OpOperand &use :
2606 use.getOwner()->getParentRegion())) {
2607 rewriter.startOpModification(use.getOwner());
2608 use.set(std::get<1>(it));
2609 rewriter.finalizeOpModification(use.getOwner());
2611 use.getOwner()->getParentRegion())) {
2612 rewriter.startOpModification(use.getOwner());
2613 use.set(std::get<2>(it));
2614 rewriter.finalizeOpModification(use.getOwner());
2687 // Cannot remove else region when there are operation results.
2772 // the else region contains just the yield, its yielded value is
3015 void ParallelOp::print(OpAsmPrinter &p) {
3016 p << " (" << getBody()->getArguments() << ") = (" << getLowerBound()
3019 p << " init (" << getInitVals() << ")";
3020 p.printOptionalArrowTypeList(getResultTypes());
3021 p << ' ';
3022 p.printRegion(getRegion(), /*printEntryBlockArgs=*/false);
3023 p.printOptionalAttrDict(
3200 /// Given the region at `index`, or the parent operation if `index` is None,
3207 // Both the operation itself and the region may be branching into the body or
3233 // The region of a ReduceOp has two arguments of the same type as its
3245 << " in the " << i << "-th reduction region";
3292 // Build before region.
3305 // Build after region.
3342 "WhileOp is expected to branch only to the first region");
3348 // The parent op always branches to the condition region.
3356 // The body region always branches back to the condition region.
3372 /// op ::= `scf.while` assignments `:` function-type region `do` region
3408 // Propagate the types into the region arguments.
3418 void scf::WhileOp::print(OpAsmPrinter &p) {
3419 printInitializationList(p, getBeforeArguments(), getInits(), " ");
3420 p << " : ";
3421 p.printFunctionalType(getInits().getTypes(), getResults().getTypes());
3422 p << ' ';
3423 p.printRegion(getBefore(), /*printEntryBlockArgs=*/false);
3424 p << " do ";
3425 p.printRegion(getAfter());
3426 p.printOptionalAttrDictWithKeyword((*this)->getAttrs());
3454 "expects the 'before' region to terminate with 'scf.condition'");
3460 "expects the 'after' region to terminate with 'scf.yield'");
3473 /// use(%arg0)
3482 /// use(%true)
3679 /// corresponding argument in `after` block and replace the use with the value.
3680 /// We also replace the use of the corresponding result of scf.while with the
3815 /// "test.use"(%arg0) : (i32) -> ()
3828 /// "test.use"(%arg0) : (i32) -> ()
3909 /// use(%condition2)
3919 /// use(%true)
4187 parseSwitchCases(OpAsmParser &p, DenseI64ArrayAttr &cases,
4190 while (succeeded(p.parseOptionalKeyword("case"))) {
4192 Region ®ion = *caseRegions.emplace_back(std::make_unique<Region>());
4193 if (p.parseInteger(value) || p.parseRegion(region, /*arguments=*/{}))
4197 cases = p.getBuilder().getDenseI64ArrayAttr(caseValues);
4202 static void printSwitchCases(OpAsmPrinter &p, Operation *op,
4204 for (auto [value, region] : llvm::zip(cases.asArrayRef(), caseRegions)) {
4205 p.printNewline();
4206 p << "case " << value << ' ';
4207 p.printRegion(*region, /*printEntryBlockArgs=*/false);
4222 auto verifyRegion = [&](Region ®ion, const Twine &name) -> LogicalResult {
4223 auto yield = dyn_cast<YieldOp>(region.front().back());
4225 return emitOpError("expected region to end with scf.yield, but got ")
4226 << region.front().back().getName();
4229 return (emitOpError("expected each region to return ")
4241 << idx << " of each region to be " << result)
4248 if (failed(verifyRegion(getDefaultRegion(), "default region")))
4251 if (failed(verifyRegion(caseRegion, "case region #" + Twine(idx))))
4292 // default region is the only successor.
4324 // If `op.getArg()` is a constant, select the region that matches with
4325 // the constant value. Use the default region if no matche is found.