@@ -37,9 +37,9 @@ class Affine_Op<string mnemonic, list<OpTrait> traits = []> :
37
37
let parser = [{ return ::parse$cppClass(parser, result); }];
38
38
}
39
39
40
- // Require regions to have affine terminator .
40
+ // Require regions to have affine.yield .
41
41
def ImplicitAffineTerminator
42
- : SingleBlockImplicitTerminator<"AffineTerminatorOp ">;
42
+ : SingleBlockImplicitTerminator<"AffineYieldOp ">;
43
43
44
44
def AffineApplyOp : Affine_Op<"apply", [NoSideEffect]> {
45
45
let summary = "affine apply operation";
@@ -114,7 +114,7 @@ def AffineForOp : Affine_Op<"for",
114
114
115
115
The `affine.for` operation represents an affine loop nest. It has one region
116
116
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
118
118
`affine.for` is printed in custom format, the terminator is omitted. The
119
119
block has one argument of [`index`](../LangRef.md#index-type) type that
120
120
represents the induction variable of the loop.
@@ -292,7 +292,7 @@ def AffineIfOp : Affine_Op<"if",
292
292
clauses. The latter may be empty (i.e. contain no blocks), meaning the
293
293
absence of the else clause. When non-empty, both regions must contain
294
294
exactly one block terminating with
295
- [`affine.terminator `](#affineterminator -operation). *Note:* when `affine.if`
295
+ [`affine.yield `](#affineyield -operation). *Note:* when `affine.if`
296
296
is printed in custom format, the terminator is omitted. These blocks must
297
297
not have any arguments.
298
298
@@ -316,14 +316,17 @@ def AffineIfOp : Affine_Op<"if",
316
316
}
317
317
```
318
318
}];
319
+ let results = (outs Variadic<AnyMemRef>:$results);
319
320
let arguments = (ins Variadic<AnyType>);
320
321
let regions = (region SizedRegion<1>:$thenRegion, AnyRegion:$elseRegion);
321
322
322
323
let skipDefaultBuilders = 1;
323
324
324
325
let builders = [
325
326
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">,
327
330
];
328
331
329
332
let extraClassDeclaration = [{
@@ -440,7 +443,7 @@ def AffineParallelOp : Affine_Op<"parallel", [ImplicitAffineTerminator]> {
440
443
steps, are positive constant integers which defaults to "1" if not present.
441
444
The lower and upper bounds specify a half-open range: the range includes the
442
445
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 ".
444
447
445
448
The lower and upper bounds of a parallel operation are represented as an
446
449
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]> {
466
469
AffineMapAttr:$upperBoundsMap,
467
470
I64ArrayAttr:$steps,
468
471
Variadic<Index>:$mapOperands);
472
+ let results = (outs Variadic<AnyMemRef>:$results);
469
473
let regions = (region SizedRegion<1>:$region);
470
474
471
475
let builders = [
472
- OpBuilder<"Builder* builder, OperationState& result,"
476
+ OpBuilder<"Builder* builder, OperationState& result, ArrayRef<Type> resultTypes, "
473
477
"ArrayRef<int64_t> ranges">,
474
- OpBuilder<"Builder* builder, OperationState& result, AffineMap lbMap,"
478
+ OpBuilder<"Builder* builder, OperationState& result, ArrayRef<Type> resultTypes, AffineMap lbMap,"
475
479
"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,"
477
481
"ValueRange lbArgs, AffineMap ubMap, ValueRange ubArgs,"
478
482
"ArrayRef<int64_t> steps">
479
483
];
@@ -581,35 +585,26 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> {
581
585
let hasFolder = 1;
582
586
}
583
587
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";
587
591
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.
592
601
```
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.
605
602
}];
603
+ let arguments = (ins Variadic<AnyMemRef>:$results);
604
+ let builders = [
605
+ OpBuilder<"Builder *builder, OperationState &result",
606
+ [{ /* nothing to do */ }]>
607
+ ];
606
608
607
- // No custom parsing/printing form.
608
- let parser = ?;
609
- let printer = ?;
610
-
611
- // Fully specified by traits.
612
- let verifier = ?;
613
609
}
614
-
615
610
#endif // AFFINE_OPS
0 commit comments