forked from OSchip/llvm-project
Add gpu.launch_func builder.
-- PiperOrigin-RevId: 247364893
This commit is contained in:
parent
e05eda9d22
commit
530439075a
|
@ -104,6 +104,11 @@ class LaunchFuncOp : public Op<LaunchFuncOp, OpTrait::AtLeastNOperands<6>::Impl,
|
|||
public:
|
||||
using Op::Op;
|
||||
|
||||
static void build(Builder *builder, OperationState *result,
|
||||
Function *kernelFunc, Value *gridSizeX, Value *gridSizeY,
|
||||
Value *gridSizeZ, Value *blockSizeX, Value *blockSizeY,
|
||||
Value *blockSizeZ, ArrayRef<Value *> kernelOperands);
|
||||
|
||||
/// The kernel function specified by the operation's `kernel` attribute.
|
||||
Function *kernel();
|
||||
/// The number of operands passed to the kernel function.
|
||||
|
|
|
@ -268,6 +268,19 @@ ParseResult LaunchOp::parse(OpAsmParser *parser, OperationState *result) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
// LaunchFuncOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void LaunchFuncOp::build(Builder *builder, OperationState *result,
|
||||
Function *kernelFunc, Value *gridSizeX,
|
||||
Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX,
|
||||
Value *blockSizeY, Value *blockSizeZ,
|
||||
ArrayRef<Value *> kernelOperands) {
|
||||
// Add grid and block sizes as op operands, followed by the data operands.
|
||||
result->addOperands(
|
||||
{gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ});
|
||||
result->addOperands(kernelOperands);
|
||||
result->addAttribute("kernel", builder->getFunctionAttr(kernelFunc));
|
||||
}
|
||||
|
||||
Function *LaunchFuncOp::kernel() {
|
||||
return this->getAttr("kernel").dyn_cast<FunctionAttr>().getValue();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue