Skip to content

Commit f071e6d

Browse files
committed
Spirv kind of works now
1 parent 29e192a commit f071e6d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

llvm/include/llvm/IR/IntrinsicsSPIRV.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ let TargetPrefix = "spv" in {
8585
def int_spv_wave_is_first_lane : DefaultAttrsIntrinsic<[llvm_i1_ty], [], [IntrConvergent]>;
8686
def int_spv_sign : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i32_ty>], [llvm_any_ty], [IntrNoMem]>;
8787
def int_spv_radians : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
88+
def int_spv_groupMemoryBarrierWithGroupSync : DefaultAttrsIntrinsic<[], [], []>;
8889

8990
// Create resource handle given the binding information. Returns a
9091
// type appropriate for the kind of resource given the set id, binding id,

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,17 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
25212521
return selectExtInst(ResVReg, ResType, I, CL::rsqrt, GL::InverseSqrt);
25222522
case Intrinsic::spv_sign:
25232523
return selectSign(ResVReg, ResType, I);
2524+
case Intrinsic::spv_groupMemoryBarrierWithGroupSync: {
2525+
Register MemSemReg = buildI32Constant(SPIRV::MemorySemantics::SequentiallyConsistent, I);
2526+
Register ScopeReg = buildI32Constant(SPIRV::Scope::Workgroup, I);
2527+
MachineBasicBlock &BB = *I.getParent();
2528+
return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpControlBarrier))
2529+
.addUse(ScopeReg)
2530+
.addUse(ScopeReg)
2531+
.addUse(MemSemReg)
2532+
.constrainAllUses(TII, TRI, RBI);
2533+
//return selectBarrier(ResVReg, ResType, I, SPIRV::OpControlBarrier, );
2534+
} break;
25242535
case Intrinsic::spv_lifetime_start:
25252536
case Intrinsic::spv_lifetime_end: {
25262537
unsigned Op = IID == Intrinsic::spv_lifetime_start ? SPIRV::OpLifetimeStart
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
define void @test_group_memory_barrier_with_group_sync() {
5+
entry:
6+
; CHECK: call void @dx.op.barrier(i32 80, i32 9)
7+
call void @llvm.spv.groupMemoryBarrierWithGroupSync()
8+
ret void
9+
}

0 commit comments

Comments
 (0)