Lines Matching defs:scf
26 using namespace mlir::scf;
29 namespace scf {
44 "scf.while op bufferization: cast incompatible");
70 /// Bufferization of scf.condition.
73 scf::ConditionOp> {
99 auto conditionOp = cast<scf::ConditionOp>(op);
100 auto whileOp = cast<scf::WhileOp>(conditionOp->getParentOp());
120 replaceOpWithNewBufferizedOp<scf::ConditionOp>(
126 /// Return the unique scf.yield op. If there are multiple or no scf.yield ops,
128 static scf::YieldOp getUniqueYieldOp(scf::ExecuteRegionOp executeRegionOp) {
129 scf::YieldOp result;
131 if (auto yieldOp = dyn_cast<scf::YieldOp>(block.getTerminator())) {
140 /// Bufferization of scf.execute_region. Can be analyzed, but bufferization not
144 ExecuteRegionOpInterface, scf::ExecuteRegionOp> {
155 auto executeRegionOp = cast<scf::ExecuteRegionOp>(op);
156 // TODO: scf.execute_region with multiple yields are not supported.
158 return op->emitOpError("op without unique scf.yield is not supported");
172 auto executeRegionOp = cast<scf::ExecuteRegionOp>(op);
177 // Note: If there is no unique scf.yield op, `verifyAnalysis` will fail.
185 auto executeRegionOp = cast<scf::ExecuteRegionOp>(op);
191 rewriter.create<scf::ExecuteRegionOp>(op->getLoc(), newResultTypes);
220 /// Bufferization of scf.if. Replace with a new scf.if that yields memrefs.
222 : public BufferizableOpInterface::ExternalModel<IfOpInterface, scf::IfOp> {
230 auto ifOp = cast<scf::IfOp>(op);
242 auto ifOp = cast<scf::IfOp>(op);
260 rewriter.create<scf::IfOp>(ifOp.getLoc(), newTypes, ifOp.getCondition(),
276 auto ifOp = cast<scf::IfOp>(op);
277 auto thenYieldOp = cast<scf::YieldOp>(ifOp.thenBlock()->getTerminator());
278 auto elseYieldOp = cast<scf::YieldOp>(ifOp.elseBlock()->getTerminator());
321 /// Bufferization of scf.index_switch. Replace with a new scf.index_switch that
325 scf::IndexSwitchOp> {
331 auto switchOp = cast<scf::IndexSwitchOp>(op);
336 cast<scf::YieldOp>(switchOp.getCaseBlock(i).getTerminator());
342 cast<scf::YieldOp>(switchOp.getDefaultBlock().getTerminator());
352 auto switchOp = cast<scf::IndexSwitchOp>(op);
369 auto newSwitchOp = rewriter.create<scf::IndexSwitchOp>(
390 auto switchOp = cast<scf::IndexSwitchOp>(op);
397 auto yieldOp = cast<scf::YieldOp>(b.getTerminator());
545 // scf.yield was already bufferized.
584 bool mayHaveZeroIterations(scf::ForOp forOp) {
592 /// Bufferization of scf.for. Replace with a new scf.for that operates on
596 scf::ForOp> {
599 auto forOp = cast<scf::ForOp>(op);
606 // scf::ForOp alone doesn't bufferize to a memory read, one of the uses of
613 // Tensor iter_args of scf::ForOps are always considered as a write.
619 auto forOp = cast<scf::ForOp>(op);
630 auto forOp = cast<scf::ForOp>(op);
640 // Interestingly, scf::ForOp's bbArg can **always** be viewed
664 auto forOp = cast<scf::ForOp>(op);
665 auto yieldOp = cast<scf::YieldOp>(forOp.getBody()->getTerminator());
703 auto forOp = cast<scf::ForOp>(op);
718 auto yieldOp = cast<scf::YieldOp>(forOp.getBody()->getTerminator());
728 auto forOp = cast<scf::ForOp>(op);
758 // Construct a new scf.for op with memref instead of tensor values.
759 auto newForOp = rewriter.create<scf::ForOp>(
782 /// Assert that yielded values of an scf.for op are equivalent to their
796 auto forOp = cast<scf::ForOp>(op);
797 auto yieldOp = cast<scf::YieldOp>(forOp.getBody()->getTerminator());
814 /// Bufferization of scf.while. Replace with a new scf.while that operates on
818 scf::WhileOp> {
821 // Tensor iter_args of scf::WhileOps are always considered as a read.
827 // Tensor iter_args of scf::WhileOps are always considered as a write.
833 auto whileOp = cast<scf::WhileOp>(op);
855 auto whileOp = cast<scf::WhileOp>(op);
882 // Interestingly, scf::WhileOp's bbArg can **always** be viewed
909 auto whileOp = cast<scf::WhileOp>(op);
946 auto whileOp = cast<scf::WhileOp>(op);
987 // Construct a new scf.while op with memref instead of tensor values.
990 auto newWhileOp = rewriter.create<scf::WhileOp>(
1030 auto whileOp = cast<scf::WhileOp>(op);
1059 // scf.condition was already bufferized.
1066 /// Assert that yielded values of an scf.while op are equivalent to their
1074 /// Not: In contrast to scf::ForOp, scf::WhileOp has two regions and the
1078 auto whileOp = cast<scf::WhileOp>(op);
1114 /// Bufferization of scf.yield. Bufferized as part of their enclosing ops, so
1118 scf::YieldOp> {
1131 if (auto ifOp = dyn_cast<scf::IfOp>(op->getParentOp())) {
1135 if (isa<scf::ExecuteRegionOp>(op->getParentOp()))
1151 auto yieldOp = cast<scf::YieldOp>(op);
1152 if (!isa<scf::ExecuteRegionOp, scf::IfOp, scf::IndexSwitchOp, scf::ForOp,
1153 scf::WhileOp>(yieldOp->getParentOp()))
1154 return yieldOp->emitError("unsupported scf::YieldOp parent");
1165 if (isa<scf::ForOp, scf::IfOp, scf::IndexSwitchOp>(
1173 dyn_cast<scf::WhileOp>(yieldOp->getParentOp())) {
1186 replaceOpWithNewBufferizedOp<scf::YieldOp>(rewriter, op, newResults);
1192 bool mayHaveZeroIterations(scf::ForallOp forallOp) {
1220 // scf::ForallOp alone doesn't bufferize to a memory read, one of the
1227 // Outputs of scf::ForallOps are always considered as a write.
1358 } // namespace scf
1361 void mlir::scf::registerBufferizableOpInterfaceExternalModels(
1363 registry.addExtension(+[](MLIRContext *ctx, scf::SCFDialect *dialect) {