Skip to content

Commit

Permalink
adding OPCode and Intrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
joaosaffran-zz committed Nov 5, 2024
1 parent fa57c7a commit cfb0d93
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsDirectX.td
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def int_dx_typedBufferLoad_checkbit
def int_dx_typedBufferStore
: DefaultAttrsIntrinsic<[], [llvm_any_ty, llvm_i32_ty, llvm_anyvector_ty]>;

def int_dx_updateCounter
: DefaultAttrsIntrinsic<[], [llvm_any_ty, llvm_anyint_ty]>;

// Cast between target extension handle types and dxil-style opaque handles
def int_dx_cast_handle : Intrinsic<[llvm_any_ty], [llvm_any_ty]>;

Expand Down
10 changes: 10 additions & 0 deletions llvm/lib/Target/DirectX/DXIL.td
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,16 @@ def BufferStore : DXILOp<69, bufferStore> {
let stages = [Stages<DXIL1_0, [all_stages]>];
}

def UpdateCounter : DXILOp<70, bufferUpdateCounter> {
let Doc = "increments/decrements a buffer counter";
let LLVMIntrinsic = int_dx_updateCounter;
let arguments = [
HandleTy, Int8Ty
];
let result = VoidTy;
let stages = [Stages<DXIL1_0, [all_stages]>];
}

def CheckAccessFullyMapped : DXILOp<71, checkAccessFullyMapped> {
let Doc = "checks whether a Sample, Gather, or Load operation "
"accessed mapped tiles in a tiled resource";
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/CodeGen/DirectX/updateCounter.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; RUN: opt -S -dxil-op-lower %s | FileCheck %s


target triple = "dxil-pc-shadermodel6.6-compute"

define void @loadv4f32() {
%buffer = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_0_0_0(
i32 0, i32 0, i32 1, i32 0, i1 false)

call void @llvm.dx.updateCounter(target("dx.TypedBuffer", <4 x float>, 0, 0, 0) %buffer, i8 -1)
ret void
}

0 comments on commit cfb0d93

Please sign in to comment.