Skip to content

Commit 0eefc21

Browse files
author
Frank Laub
authored
Allow affine.yield to have attrs (#17)
1 parent 0451fe7 commit 0eefc21

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

mlir/include/mlir/Dialect/Affine/IR/AffineOps.td

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -769,12 +769,14 @@ def AffineYieldOp : Affine_Op<"yield", [NoSideEffect, Terminator]> {
769769
yielded.
770770
```
771771
}];
772-
let arguments = (ins Variadic<AnyType>:$results);
773-
let builders = [
774-
OpBuilder<"OpBuilder &builder, OperationState &result",
775-
[{ /* nothing to do */ }]>
776-
];
777772

773+
let arguments = (ins Variadic<AnyType>:$operands);
774+
775+
let builders = [OpBuilder<
776+
"OpBuilder &b, OperationState &result", [{ build(b, result, llvm::None); }]
777+
>];
778+
779+
let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
778780
}
779781

780782
def AffineVectorLoadOp : AffineLoadOpBase<"vector_load", []> {

mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,7 @@ struct AffineParallelRank0LoopRemover
24512451
auto &parentOps = rewriter.getInsertionBlock()->getOperations();
24522452
auto &parallelBodyOps = op.region().front().getOperations();
24532453
auto yield = mlir::cast<AffineYieldOp>(std::prev(parallelBodyOps.end()));
2454-
for (auto it : zip(op.getResults(), yield.results())) {
2454+
for (auto it : zip(op.getResults(), yield.operands())) {
24552455
std::get<0>(it).replaceAllUsesWith(std::get<1>(it));
24562456
}
24572457
parentOps.splice(mlir::Block::iterator(op), parallelBodyOps,
@@ -2658,24 +2658,6 @@ static LogicalResult verify(AffineYieldOp op) {
26582658
return success();
26592659
}
26602660

2661-
static ParseResult parseAffineYieldOp(OpAsmParser &parser,
2662-
OperationState &result) {
2663-
SmallVector<OpAsmParser::OperandType, 4> operands;
2664-
SmallVector<Type, 4> types;
2665-
llvm::SMLoc loc = parser.getCurrentLocation();
2666-
// Parse variadic operands list, their types, and resolve operands to SSA
2667-
// values.
2668-
return failure(parser.parseOperandList(operands) ||
2669-
parser.parseOptionalColonTypeList(types) ||
2670-
parser.resolveOperands(operands, types, loc, result.operands));
2671-
}
2672-
2673-
static void print(OpAsmPrinter &p, AffineYieldOp op) {
2674-
p << op.getOperationName();
2675-
if (op.getNumOperands() != 0)
2676-
p << ' ' << op.getOperands() << " : " << op.getOperandTypes();
2677-
}
2678-
26792661
//===----------------------------------------------------------------------===//
26802662
// AffineVectorLoadOp
26812663
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)