[PATCH] D73465: Add gpu::LaunchOp::addKernelArgument.
Stephan Herhut via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 28 03:18:59 PST 2020
herhut updated this revision to Diff 240821.
herhut added a comment.
Split out gpu dialect cleanup parts.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73465/new/
https://reviews.llvm.org/D73465
Files:
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Index: mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
===================================================================
--- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -201,6 +201,8 @@
result.addOperands(
{gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ});
result.addOperands(operands);
+ // We want to be able to add operands later, for instance due to code motion.
+ result.setOperandListToResizable();
// Create a kernel body region with kNumConfigRegionAttributes + N arguments,
// where the first kNumConfigRegionAttributes arguments have `index` type and
@@ -449,6 +451,15 @@
getOperation()->eraseOperand(kNumConfigOperands + index);
}
+BlockArgument LaunchOp::addKernelArgument(Value value) {
+ Block &entryBlock = body().front();
+ Operation *op = getOperation();
+ llvm::SmallVector<Value, 8> operands(op->getOperands());
+ operands.push_back(value);
+ op->setOperands(operands);
+ return entryBlock.addArgument(value.getType());
+}
+
namespace {
// Clone any known constants passed as operands to the kernel into its body.
class PropagateConstantBounds : public OpRewritePattern<LaunchOp> {
Index: mlir/include/mlir/Dialect/GPU/GPUOps.td
===================================================================
--- mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -454,6 +454,10 @@
/// the operand will be dropped. The block argument must not have any uses.
void eraseKernelArgument(unsigned index);
+ /// Add the given value as a kernel argument. Returns the corresponding newly
+ /// added BlockArgument.
+ BlockArgument addKernelArgument(Value argument);
+
static StringRef getBlocksKeyword() { return "blocks"; }
static StringRef getThreadsKeyword() { return "threads"; }
static StringRef getArgsKeyword() { return "args"; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73465.240821.patch
Type: text/x-patch
Size: 1902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200128/937f23c3/attachment.bin>
More information about the llvm-commits
mailing list