Skip to content

Commit accfbf4

Browse files
authored
[MLIR][ROCDL] Add BallotOp and lit test (llvm#84856)
1 parent bb5921e commit accfbf4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ Arguments<(ins I32:$index,
158158
}];
159159
}
160160

161+
def ROCDL_BallotOp :
162+
ROCDL_Op<"ballot">,
163+
Results<(outs LLVM_Type:$res)>,
164+
Arguments<(ins I1:$pred)> {
165+
string llvmBuilder = [{
166+
$res = createIntrinsicCall(builder,
167+
llvm::Intrinsic::amdgcn_ballot, {$pred}, {llvm::Type::getInt32Ty(moduleTranslation.getLLVMContext())});
168+
}];
169+
let assemblyFormat = "$pred attr-dict `:` type($res)";
170+
}
161171

162172
//===----------------------------------------------------------------------===//
163173
// Thread index and Block index

mlir/test/Target/LLVMIR/rocdl.mlir

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ llvm.func @rocdl.bpermute(%src : i32) -> i32 {
8888
llvm.return %0 : i32
8989
}
9090

91+
llvm.func @rocdl.ballot(%pred : i1) -> i32 {
92+
// CHECK-LABEL: rocdl.ballot
93+
// CHECK: call i32 @llvm.amdgcn.ballot
94+
%0 = rocdl.ballot %pred : i32
95+
llvm.return %0 : i32
96+
}
97+
9198
llvm.func @rocdl.waitcnt() {
9299
// CHECK-LABEL: rocdl.waitcnt
93100
// CHECK-NEXT: call void @llvm.amdgcn.s.waitcnt(i32 0)

0 commit comments

Comments
 (0)