diff options
author | River Riddle <riverriddle@google.com> | 2019-12-12 15:31:39 -0800 |
---|---|---|
committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-12 15:32:21 -0800 |
commit | e7aa47ff111c53127587d8aea71b088db3a671aa (patch) | |
tree | f2b4841362b381de4f2beb1632250b8cdbc49cf2 /mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | |
parent | a50cb184a0c5ebc342a871b2e338e2591115639f (diff) | |
download | bcm5719-llvm-e7aa47ff111c53127587d8aea71b088db3a671aa.tar.gz bcm5719-llvm-e7aa47ff111c53127587d8aea71b088db3a671aa.zip |
NFC: Cleanup the various Op::print methods.
This cleans up the implementation of the various operation print methods. This is done via a combination of code cleanup, adding new streaming methods to the printer(e.g. operand ranges), etc.
PiperOrigin-RevId: 285285181
Diffstat (limited to 'mlir/lib/Dialect/GPU/IR/GPUDialect.cpp')
-rw-r--r-- | mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index b8970650806..1f48d6d47e4 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -289,8 +289,7 @@ void printLaunchOp(OpAsmPrinter &p, LaunchOp op) { // Print the launch configuration. p << LaunchOp::getOperationName() << ' ' << op.getBlocksKeyword(); - printSizeAssignment(p, op.getGridSize(), - operands.drop_back(operands.size() - 3), + printSizeAssignment(p, op.getGridSize(), operands.take_front(3), op.getBlockIds()); p << ' ' << op.getThreadsKeyword(); printSizeAssignment(p, op.getBlockSize(), operands.slice(3, 3), @@ -303,25 +302,17 @@ void printLaunchOp(OpAsmPrinter &p, LaunchOp op) { // Print the data argument remapping. if (!op.body().empty() && !operands.empty()) { p << ' ' << op.getArgsKeyword() << '('; - for (unsigned i = 0, e = operands.size(); i < e; ++i) { - if (i != 0) - p << ", "; - p << *op.body().front().getArgument(LaunchOp::kNumConfigRegionAttributes + - i) + Block *entryBlock = &op.body().front(); + interleaveComma(llvm::seq<int>(0, operands.size()), p, [&](int i) { + p << *entryBlock->getArgument(LaunchOp::kNumConfigRegionAttributes + i) << " = " << *operands[i]; - } + }); p << ") "; } // Print the types of data arguments. - if (!operands.empty()) { - p << ": "; - for (unsigned i = 0, e = operands.size(); i < e; ++i) { - if (i != 0) - p << ", "; - p << operands[i]->getType(); - } - } + if (!operands.empty()) + p << ": " << operands.getTypes(); p.printRegion(op.body(), /*printEntryBlockArgs=*/false); p.printOptionalAttrDict(op.getAttrs()); @@ -701,7 +692,7 @@ static void printAttributions(OpAsmPrinter &p, StringRef keyword, return; p << ' ' << keyword << '('; - interleaveComma(values, p.getStream(), + interleaveComma(values, p, [&p](BlockArgument *v) { p << *v << " : " << v->getType(); }); p << ')'; } |