Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions llvm/lib/Target/DirectX/DXIL.td
Original file line number Diff line number Diff line change
Expand Up @@ -671,26 +671,29 @@ def Dot4 : DXILOp<56, dot4> {
def ThreadId : DXILOp<93, threadId> {
let Doc = "Reads the thread ID";
let LLVMIntrinsic = int_dx_thread_id;
let arguments = [i32Ty];
let result = i32Ty;
let arguments = [overloadTy];
let result = overloadTy;
let overloads = [Overloads<DXIL1_0, [i32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}

def GroupId : DXILOp<94, groupId> {
let Doc = "Reads the group ID (SV_GroupID)";
let LLVMIntrinsic = int_dx_group_id;
let arguments = [i32Ty];
let result = i32Ty;
let arguments = [overloadTy];
let result = overloadTy;
let overloads = [Overloads<DXIL1_0, [i32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}

def ThreadIdInGroup : DXILOp<95, threadIdInGroup> {
let Doc = "Reads the thread ID within the group (SV_GroupThreadID)";
let LLVMIntrinsic = int_dx_thread_id_in_group;
let arguments = [i32Ty];
let result = i32Ty;
let arguments = [overloadTy];
let result = overloadTy;
let overloads = [Overloads<DXIL1_0, [i32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
Expand All @@ -699,7 +702,8 @@ def FlattenedThreadIdInGroup : DXILOp<96, flattenedThreadIdInGroup> {
let Doc = "Provides a flattened index for a given thread within a given "
"group (SV_GroupIndex)";
let LLVMIntrinsic = int_dx_flattened_thread_id_in_group;
let result = i32Ty;
let result = overloadTy;
let overloads = [Overloads<DXIL1_0, [i32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
9 changes: 4 additions & 5 deletions llvm/lib/Target/DirectX/DXILOpBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ static const char *getOverloadTypeName(OverloadKind Kind) {
}

static OverloadKind getOverloadKind(Type *Ty) {
if (!Ty)
return OverloadKind::VOID;

Type::TypeID T = Ty->getTypeID();
switch (T) {
case Type::VoidTyID:
Expand Down Expand Up @@ -379,11 +382,7 @@ Expected<CallInst *> DXILOpBuilder::tryCreateOp(dxil::OpCode OpCode,

uint16_t ValidTyMask = Prop->Overloads[*OlIndexOrErr].ValidTys;

// If we don't have an overload type, use the function's return type. This is
// a bit of a hack, but it's necessary to get the type suffix on unoverloaded
// DXIL ops correct, like `dx.op.threadId.i32`.
OverloadKind Kind =
getOverloadKind(OverloadTy ? OverloadTy : DXILOpFT->getReturnType());
OverloadKind Kind = getOverloadKind(OverloadTy);

// Check if the operation supports overload types and OverloadTy is valid
// per the specified types for the operation
Expand Down