@@ -37,9 +37,9 @@ class Affine_Op<string mnemonic, list<OpTrait> traits = []> :
3737 let parser = [{ return ::parse$cppClass(parser, result); }];
3838}
3939
40- // Require regions to have affine terminator .
40+ // Require regions to have affine.yield .
4141def ImplicitAffineTerminator
42- : SingleBlockImplicitTerminator<"AffineTerminatorOp ">;
42+ : SingleBlockImplicitTerminator<"AffineYieldOp ">;
4343
4444def AffineApplyOp : Affine_Op<"apply", [NoSideEffect]> {
4545 let summary = "affine apply operation";
@@ -114,7 +114,7 @@ def AffineForOp : Affine_Op<"for",
114114
115115 The `affine.for` operation represents an affine loop nest. It has one region
116116 containing its body. This region must contain one block that terminates with
117- [`affine.terminator `](#affineterminator -operation). *Note:* when
117+ [`affine.yield `](#affinyield -operation). *Note:* when
118118 `affine.for` is printed in custom format, the terminator is omitted. The
119119 block has one argument of [`index`](../LangRef.md#index-type) type that
120120 represents the induction variable of the loop.
@@ -292,7 +292,7 @@ def AffineIfOp : Affine_Op<"if",
292292 clauses. The latter may be empty (i.e. contain no blocks), meaning the
293293 absence of the else clause. When non-empty, both regions must contain
294294 exactly one block terminating with
295- [`affine.terminator `](#affineterminator -operation). *Note:* when `affine.if`
295+ [`affine.yield `](#affineyield -operation). *Note:* when `affine.if`
296296 is printed in custom format, the terminator is omitted. These blocks must
297297 not have any arguments.
298298
@@ -316,14 +316,17 @@ def AffineIfOp : Affine_Op<"if",
316316 }
317317 ```
318318 }];
319+ let results = (outs Variadic<AnyMemRef>:$results);
319320 let arguments = (ins Variadic<AnyType>);
320321 let regions = (region SizedRegion<1>:$thenRegion, AnyRegion:$elseRegion);
321322
322323 let skipDefaultBuilders = 1;
323324
324325 let builders = [
325326 OpBuilder<"Builder *builder, OperationState &result, "
326- "IntegerSet set, ValueRange args, bool withElseRegion">
327+ "IntegerSet set, ValueRange args, bool withElseRegion">,
328+ OpBuilder<"Builder *builder, OperationState &result, TypeRange resultTypes, "
329+ "IntegerSet set, ValueRange args, bool withElseRegion">,
327330 ];
328331
329332 let extraClassDeclaration = [{
@@ -440,7 +443,7 @@ def AffineParallelOp : Affine_Op<"parallel", [ImplicitAffineTerminator]> {
440443 steps, are positive constant integers which defaults to "1" if not present.
441444 The lower and upper bounds specify a half-open range: the range includes the
442445 lower bound but does not include the upper bound. The body region must
443- contain exactly one block that terminates with "affine.terminator ".
446+ contain exactly one block that terminates with "affine.yield ".
444447
445448 The lower and upper bounds of a parallel operation are represented as an
446449 application of an affine mapping to a list of SSA values passed to the map.
@@ -466,14 +469,15 @@ def AffineParallelOp : Affine_Op<"parallel", [ImplicitAffineTerminator]> {
466469 AffineMapAttr:$upperBoundsMap,
467470 I64ArrayAttr:$steps,
468471 Variadic<Index>:$mapOperands);
472+ let results = (outs Variadic<AnyMemRef>:$results);
469473 let regions = (region SizedRegion<1>:$region);
470474
471475 let builders = [
472- OpBuilder<"Builder* builder, OperationState& result,"
476+ OpBuilder<"Builder* builder, OperationState& result, ArrayRef<Type> resultTypes, "
473477 "ArrayRef<int64_t> ranges">,
474- OpBuilder<"Builder* builder, OperationState& result, AffineMap lbMap,"
478+ OpBuilder<"Builder* builder, OperationState& result, ArrayRef<Type> resultTypes, AffineMap lbMap,"
475479 "ValueRange lbArgs, AffineMap ubMap, ValueRange ubArgs">,
476- OpBuilder<"Builder* builder, OperationState& result, AffineMap lbMap,"
480+ OpBuilder<"Builder* builder, OperationState& result, ArrayRef<Type> resultTypes, AffineMap lbMap,"
477481 "ValueRange lbArgs, AffineMap ubMap, ValueRange ubArgs,"
478482 "ArrayRef<int64_t> steps">
479483 ];
@@ -581,35 +585,26 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> {
581585 let hasFolder = 1;
582586}
583587
584- def AffineTerminatorOp :
585- Affine_Op<"terminator", [NoSideEffect, Terminator] > {
586- let summary = "affine terminator operation";
588+ def AffineYieldOp : Affine_Op<"yield", [NoSideEffect, Terminator]>,
589+ Arguments<(ins Variadic<AnyMemRef>:$values) > {
590+ let summary = "Yield values to parent operation";
587591 let description = [{
588- Syntax:
589-
590- ```
591- operation ::= `"affine.terminator"() : () -> ()`
592+ "affine.yield" yields zero or more SSA values from an affine op region and
593+ terminates the region. The semantics of how the values yielded are used
594+ is defined by the parent operation.
595+ If "affine.yield" has any operands, the operands must match the parent
596+ operation's results.
597+ If the parent operation defines no values, then the "affine.yield" may be
598+ left out in the custom syntax and the builders will insert one implicitly.
599+ Otherwise, it has to be present in the syntax to indicate which values are
600+ yielded.
592601 ```
593-
594- Affine terminator is a special terminator operation for blocks inside affine
595- loops ([`affine.for`](#affinefor-operation)) and branches
596- ([`affine.if`](#affineif-operation)). It unconditionally transmits the
597- control flow to the successor of the operation enclosing the region.
598-
599- *Rationale*: bodies of affine operations are [blocks](../LangRef.md#blocks)
600- that must have terminators. Loops and branches represent structured control
601- flow and should not accept arbitrary branches as terminators.
602-
603- This operation does _not_ have a custom syntax. However, affine control
604- operations omit the terminator in their custom syntax for brevity.
605602 }];
603+ let arguments = (ins Variadic<AnyMemRef>:$results);
604+ let builders = [
605+ OpBuilder<"Builder *builder, OperationState &result",
606+ [{ /* nothing to do */ }]>
607+ ];
606608
607- // No custom parsing/printing form.
608- let parser = ?;
609- let printer = ?;
610-
611- // Fully specified by traits.
612- let verifier = ?;
613609}
614-
615610#endif // AFFINE_OPS
0 commit comments