[mlir][GPU] Add ShuffleOp builder for constant offset/width

Differential Revision: https://reviews.llvm.org/D119345
This commit is contained in:
Matthias Springer 2022-02-10 01:21:55 +09:00
parent e92ff1b4fa
commit 69f7647158
2 changed files with 21 additions and 0 deletions

View File

@ -724,6 +724,11 @@ def GPU_ShuffleOp : GPU_Op<
in the shuffle. Exactly the first `width` invocations of a subgroup need to
execute this op in convergence.
}];
let builders = [
// Helper function that creates a shuffle with constant offset/width.
OpBuilder<(ins "Value":$value, "int32_t":$offset, "int32_t":$width,
"ShuffleMode":$mode)>
];
let assemblyFormat = "$mode $value `,` $offset `,` $width attr-dict `:` type($value)";
}

View File

@ -691,6 +691,22 @@ static void printLaunchFuncOperands(OpAsmPrinter &printer, Operation *,
printer << ")";
}
//
//===----------------------------------------------------------------------===//
// ShuffleOp
//===----------------------------------------------------------------------===//
void ShuffleOp::build(OpBuilder &builder, OperationState &result, Value value,
int32_t offset, int32_t width, ShuffleMode mode) {
build(builder, result, value,
builder.create<arith::ConstantOp>(result.location,
builder.getI32IntegerAttr(offset)),
builder.create<arith::ConstantOp>(result.location,
builder.getI32IntegerAttr(width)),
mode);
}
//===----------------------------------------------------------------------===//
// GPUFuncOp
//===----------------------------------------------------------------------===//