Skip to content

Commit 06ad11a

Browse files
committed
works without cafm
1 parent 99c9788 commit 06ad11a

File tree

12 files changed

+139
-47
lines changed

12 files changed

+139
-47
lines changed

clang/include/clang/Basic/Builtins.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4934,8 +4934,8 @@ def HLSLResourceGetPointer : LangBuiltin<"HLSL_LANG"> {
49344934
let Prototype = "void(...)";
49354935
}
49364936

4937-
def HLSLResourceGetPointerWithStatus : LangBuiltin<"HLSL_LANG"> {
4938-
let Spellings = ["__builtin_hlsl_resource_getpointer_with_status"];
4937+
def HLSLResourceLoadWithStatus : LangBuiltin<"HLSL_LANG"> {
4938+
let Spellings = ["__builtin_hlsl_resource_load_with_status"];
49394939
let Attributes = [NoThrow];
49404940
let Prototype = "void(...)";
49414941
}

clang/lib/CodeGen/CGHLSLBuiltins.cpp

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,53 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
353353
RetTy, CGM.getHLSLRuntime().getCreateResourceGetPointerIntrinsic(),
354354
ArrayRef<Value *>{HandleOp, IndexOp});
355355
}
356-
case Builtin::BI__builtin_hlsl_resource_getpointer_with_status: {
356+
case Builtin::BI__builtin_hlsl_resource_load_with_status: {
357357
Value *HandleOp = EmitScalarExpr(E->getArg(0));
358358
Value *IndexOp = EmitScalarExpr(E->getArg(1));
359-
Value *StatusOp = EmitScalarExpr(E->getArg(2));
360359

361-
llvm::Type *RetTy = ConvertType(E->getType());
362-
return Builder.CreateIntrinsic(
363-
RetTy,
364-
CGM.getHLSLRuntime().getCreateResourceGetPointerWithStatusIntrinsic(),
365-
ArrayRef<Value *>{HandleOp, IndexOp, StatusOp});
360+
// Get the *address* of the status argument (since it's a reference)
361+
LValue StatusLVal = EmitLValue(E->getArg(2));
362+
Address StatusAddr = StatusLVal.getAddress();
363+
364+
QualType HandleTy = E->getArg(0)->getType();
365+
const HLSLAttributedResourceType *RT =
366+
HandleTy->getAs<HLSLAttributedResourceType>();
367+
assert(RT && "Expected a resource type as first parameter");
368+
369+
Intrinsic::ID IntrID = RT->getAttrs().RawBuffer
370+
? llvm::Intrinsic::dx_resource_load_rawbuffer
371+
: llvm::Intrinsic::dx_resource_load_typedbuffer;
372+
373+
llvm::Type *DataTy = ConvertType(E->getType());
374+
llvm::Type *RetTy = llvm::StructType::get(Builder.getContext(),
375+
{DataTy, Builder.getInt1Ty()});
376+
377+
SmallVector<Value *, 3> Args;
378+
Args.push_back(HandleOp);
379+
Args.push_back(IndexOp);
380+
381+
if (RT->getAttrs().RawBuffer) {
382+
Args.push_back(Builder.getInt32(0)); // dummy offset
383+
}
384+
385+
// Call the intrinsic (returns a struct)
386+
Value *ResRet =
387+
Builder.CreateIntrinsic(RetTy, IntrID, Args, {}, "ld.struct");
388+
389+
// Extract the loaded data (first element of the struct)
390+
Value *LoadedValue = Builder.CreateExtractValue(ResRet, {0}, "ld.value");
391+
392+
// Extract the status bit (second element of the struct)
393+
Value *StatusBit = Builder.CreateExtractValue(ResRet, {1}, "ld.status");
394+
395+
// Extend the status bit to a 32-bit integer
396+
Value *ExtendedStatus =
397+
Builder.CreateZExt(StatusBit, Builder.getInt32Ty(), "ld.status.ext");
398+
399+
// Store the extended status into the user's reference variable
400+
Builder.CreateStore(ExtendedStatus, StatusAddr);
401+
402+
return LoadedValue;
366403
}
367404
case Builtin::BI__builtin_hlsl_resource_uninitializedhandle: {
368405
llvm::Type *HandleTy = CGM.getTypes().ConvertType(E->getType());

clang/lib/CodeGen/CGHLSLRuntime.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ class CGHLSLRuntime {
126126

127127
GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetPointer,
128128
resource_getpointer)
129-
GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetPointerWithStatus,
130-
resource_getpointer_with_status)
129+
130+
GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceLoadTypedBuffer,
131+
resource_load_typedbuffer)
131132
GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromBinding,
132133
resource_handlefrombinding)
133134
GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromImplicitBinding,

clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addLoadMethods() {
11401140
DeclarationName Load(&II);
11411141
// TODO: We also need versions with status for CheckAccessFullyMapped.
11421142
addHandleAccessFunction(Load, /*IsConst=*/false, /*IsRef=*/false);
1143-
addHandleAccessFunctionWithStatus(Load, /*IsConst=*/false, /*IsRef=*/false);
1143+
addLoadWithStatusFunction(Load, /*IsConst=*/false, /*IsRef=*/false);
11441144

11451145
return *this;
11461146
}
@@ -1234,9 +1234,8 @@ BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addDecrementCounterMethod() {
12341234
}
12351235

12361236
BuiltinTypeDeclBuilder &
1237-
BuiltinTypeDeclBuilder::addHandleAccessFunctionWithStatus(DeclarationName &Name,
1238-
bool IsConst,
1239-
bool IsRef) {
1237+
BuiltinTypeDeclBuilder::addLoadWithStatusFunction(DeclarationName &Name,
1238+
bool IsConst, bool IsRef) {
12401239
assert(!Record->isCompleteDefinition() && "record is already complete");
12411240
ASTContext &AST = SemaRef.getASTContext();
12421241
using PH = BuiltinTypeMethodBuilder::PlaceHolder;
@@ -1262,7 +1261,7 @@ BuiltinTypeDeclBuilder::addHandleAccessFunctionWithStatus(DeclarationName &Name,
12621261
return BuiltinTypeMethodBuilder(*this, Name, ReturnTy, IsConst)
12631262
.addParam("Index", AST.UnsignedIntTy)
12641263
.addParam("Status", StatusRefTy)
1265-
.callBuiltin("__builtin_hlsl_resource_getpointer_with_status", ElemPtrTy,
1264+
.callBuiltin("__builtin_hlsl_resource_load_with_status", ElemPtrTy,
12661265
PH::Handle, PH::_0, PH::_1)
12671266
.dereference(PH::LastStmt)
12681267
.finalize();

clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ class BuiltinTypeDeclBuilder {
9191
BuiltinTypeDeclBuilder &addDecrementCounterMethod();
9292
BuiltinTypeDeclBuilder &addHandleAccessFunction(DeclarationName &Name,
9393
bool IsConst, bool IsRef);
94-
BuiltinTypeDeclBuilder &
95-
addHandleAccessFunctionWithStatus(DeclarationName &Name, bool IsConst,
96-
bool IsRef);
94+
BuiltinTypeDeclBuilder &addLoadWithStatusFunction(DeclarationName &Name,
95+
bool IsConst, bool IsRef);
9796
BuiltinTypeDeclBuilder &addAppendMethod();
9897
BuiltinTypeDeclBuilder &addConsumeMethod();
9998

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
30103010

30113011
break;
30123012
}
3013-
case Builtin::BI__builtin_hlsl_resource_getpointer_with_status: {
3013+
case Builtin::BI__builtin_hlsl_resource_load_with_status: {
30143014
if (SemaRef.checkArgCount(TheCall, 3) ||
30153015
CheckResourceHandle(&SemaRef, TheCall, 0) ||
30163016
CheckArgTypeMatches(&SemaRef, TheCall->getArg(1),

clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,42 @@ export float TestLoad() {
107107
export float TestLoadWithStatus() {
108108
uint s1;
109109
uint s2;
110-
float ret = RWSB1.Load(1, s) + SB1.Load(2, s2);
110+
float ret = RWSB1.Load(1, s1) + SB1.Load(2, s2);
111111
ret += float(s1 + s2);
112112
return ret;
113113
}
114114

115-
// CHECK: define noundef nofpclass(nan inf) float @TestLoad()()
116-
// CHECK: call {{.*}} float @hlsl::RWStructuredBuffer<float>::Load(unsigned int)(ptr {{.*}} @RWSB1, i32 noundef 1)
117-
// CHECK: call {{.*}} float @hlsl::StructuredBuffer<float>::Load(unsigned int)(ptr {{.*}} @SB1, i32 noundef 2)
115+
// CHECK: define noundef nofpclass(nan inf) float @TestLoadWithStatus()()
116+
// CHECK: call {{.*}} float @hlsl::RWStructuredBuffer<float>::Load(unsigned int, unsigned int&)(ptr {{.*}} @RWSB1, i32 noundef 1, ptr noundef nonnull align 4 dereferenceable(4) %s1)
117+
// CHECK: call {{.*}} float @hlsl::StructuredBuffer<float>::Load(unsigned int, unsigned int&)(ptr {{.*}} @SB1, i32 noundef 2, ptr noundef nonnull align 4 dereferenceable(4) %s2)
118118
// CHECK: add
119119
// CHECK: ret float
120120

121-
// CHECK: define {{.*}} float @hlsl::RWStructuredBuffer<float>::Load(unsigned int)(ptr {{.*}} %this, i32 noundef %Index)
121+
// CHECK: define {{.*}} float @hlsl::RWStructuredBuffer<float>::Load(unsigned int, unsigned int&)(ptr {{.*}} %this, i32 noundef %Index, ptr noundef nonnull align 4 dereferenceable(4) %Status)
122122
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RWStructuredBuffer", ptr %{{.*}}, i32 0, i32 0
123123
// DXIL-NEXT: %[[HANDLE:.*]] = load target("dx.RawBuffer", float, 1, 0), ptr %__handle
124124
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
125-
// DXIL-NEXT: %[[PTR:.*]] = call ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", float, 1, 0) %[[HANDLE]], i32 %[[INDEX]])
126-
// CHECK-NEXT: %[[VAL:.*]] = load float, ptr %[[PTR]]
127-
// CHECK-NEXT: ret float %[[VAL]]
128-
129-
// CHECK: define {{.*}} float @hlsl::StructuredBuffer<float>::Load(unsigned int)(ptr {{.*}} %this, i32 noundef %Index)
125+
// CHECK-NEXT: %[[STATUS:.*]] = load ptr, ptr %Status.addr,
126+
// DXIL-NEXT: %[[STRUCT:.*]] = call { ptr, i1 } @llvm.dx.resource.load.rawbuffer.p0.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", float, 1, 0) %[[HANDLE]], i32 %[[INDEX]], i32 0)
127+
// CHECK-NEXT: %[[VALUE:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 0
128+
// CHECK-NEXT: %[[STATUS_TEMP:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 1
129+
// CHECK-NEXT: %[[STATUS_EXT:.*]] = zext i1 %[[STATUS_TEMP]] to i32
130+
// CHECK-NEXT: store i32 %[[STATUS_EXT]], ptr %2, align 4
131+
// CHECK-NEXT: %[[RETVAL:.*]] = load float, ptr %[[VALUE]]
132+
// CHECK-NEXT: ret float %[[RETVAL]]
133+
134+
// CHECK: define {{.*}} float @hlsl::StructuredBuffer<float>::Load(unsigned int, unsigned int&)(ptr {{.*}} %this, i32 noundef %Index, ptr noundef nonnull align 4 dereferenceable(4) %Status)
130135
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::StructuredBuffer", ptr %{{.*}}, i32 0, i32 0
131136
// DXIL-NEXT: %[[HANDLE:.*]] = load target("dx.RawBuffer", float, 0, 0), ptr %__handle
132137
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
133-
// DXIL-NEXT: %[[PTR:.*]] = call ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_0_0t(target("dx.RawBuffer", float, 0, 0) %[[HANDLE]], i32 %[[INDEX]])
134-
// CHECK-NEXT: %[[VAL:.*]] = load float, ptr %[[PTR]]
135-
// CHECK-NEXT: ret float %[[VAL]]
138+
// CHECK-NEXT: %[[STATUS_HANDLE:.*]] = load ptr, ptr %Status.addr, align 4, !nonnull !3, !align !4
139+
// DXIL-NEXT: %[[STRUCT:.*]] = call { ptr, i1 } @llvm.dx.resource.load.rawbuffer.p0.tdx.RawBuffer_f32_0_0t(target("dx.RawBuffer", float, 0, 0) %0, i32 %1, i32 0)
140+
// CHECK-NEXT: %[[VALUE:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 0
141+
// CHECK-NEXT: %[[STATUS:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 1
142+
// CHECK-NEXT: %[[STATUS_EXT:.*]] = zext i1 %[[STATUS]] to i32
143+
// CHECK-NEXT: store i32 %[[STATUS_EXT]], ptr %2, align 4
144+
// CHECK-NEXT: %[[RETVAL:.*]] = load float, ptr %[[VALUE]]
145+
// CHECK-NEXT: ret float %[[RETVAL]]
136146

137147
export uint TestGetDimensions() {
138148
uint dim1, dim2, dim3, stride1, stride2, stride3;

clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,27 @@ export float TestLoadWithStatus() {
8181
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RasterizerOrderedStructuredBuffer", ptr {{.*}}, i32 0, i32 0
8282
// CHECK-NEXT: %[[HANDLE:.*]] = load target("dx.RawBuffer", float, 1, 1), ptr %__handle
8383
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
84-
// CHECK-NEXT: %[[STATUS_HANDLE:.*]] = load ptr, ptr %Status.addr, align 4, !nonnull !3, !align !4
85-
// CHECK-NEXT: %[[STATUS:.*]] = load i32, ptr %[[STATUS_HANDLE]], align 4
86-
// DXIL-NEXT: %[[BUFPTR:.*]] = call ptr @llvm.dx.resource.getpointer.with.status.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", float, 1, 1) %[[HANDLE]], i32 %[[INDEX]], i32 %[[STATUS]])
87-
// CHECK-NEXT: %[[VAL:.*]] = load float, ptr %[[BUFPTR]]
88-
// CHECK-NEXT: ret float %[[VAL]]
84+
// CHECK-NEXT: %[[STATUS:.*]] = load ptr, ptr %Status.addr,
85+
// DXIL-NEXT: %[[STRUCT:.*]] = call { ptr, i1 } @llvm.dx.resource.load.rawbuffer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", float, 1, 1) %[[HANDLE]], i32 %[[INDEX]], i32 0)
86+
// CHECK-NEXT: %[[VALUE:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 0
87+
// CHECK-NEXT: %[[STATUS_TEMP:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 1
88+
// CHECK-NEXT: %[[STATUS_EXT:.*]] = zext i1 %[[STATUS_TEMP]] to i32
89+
// CHECK-NEXT: store i32 %[[STATUS_EXT]], ptr %2, align 4
90+
// CHECK-NEXT: %[[RETVAL:.*]] = load float, ptr %[[VALUE]]
91+
// CHECK-NEXT: ret float %[[RETVAL]]
8992

9093
// CHECK: define {{.*}} <2 x i32> @hlsl::RasterizerOrderedStructuredBuffer<int vector[2]>::Load(unsigned int, unsigned int&)(ptr {{.*}} %Index, ptr noundef nonnull align 4 dereferenceable(4) %Status)
9194
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RasterizerOrderedStructuredBuffer.0", ptr {{.*}}, i32 0, i32 0
9295
// CHECK-NEXT: %[[HANDLE:.*]] = load target("dx.RawBuffer", <2 x i32>, 1, 1), ptr %__handle
9396
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
9497
// CHECK-NEXT: %[[STATUS_HANDLE:.*]] = load ptr, ptr %Status.addr, align 4, !nonnull !3, !align !4
95-
// CHECK-NEXT: %[[STATUS:.*]] = load i32, ptr %[[STATUS_HANDLE]], align 4
96-
// DXIL-NEXT: %[[BUFPTR:.*]] = call ptr @llvm.dx.resource.getpointer.with.status.p0.tdx.RawBuffer_v2i32_1_1t(target("dx.RawBuffer", <2 x i32>, 1, 1) %[[HANDLE]], i32 %[[INDEX]], i32 %[[STATUS]])
97-
// CHECK-NEXT: %[[VAL:.*]] = load <2 x i32>, ptr %[[BUFPTR]]
98-
// CHECK-NEXT: ret <2 x i32> %[[VAL]]
98+
// DXIL-NEXT: %[[STRUCT:.*]] = call { ptr, i1 } @llvm.dx.resource.load.rawbuffer.p0.tdx.RawBuffer_v2i32_1_1t(target("dx.RawBuffer", <2 x i32>, 1, 1) %0, i32 %1, i32 0)
99+
// CHECK-NEXT: %[[VALUE:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 0
100+
// CHECK-NEXT: %[[STATUS:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 1
101+
// CHECK-NEXT: %[[STATUS_EXT:.*]] = zext i1 %[[STATUS]] to i32
102+
// CHECK-NEXT: store i32 %[[STATUS_EXT]], ptr %2, align 4
103+
// CHECK-NEXT: %[[RETVAL:.*]] = load <2 x i32>, ptr %[[VALUE]]
104+
// CHECK-NEXT: ret <2 x i32> %[[RETVAL]]
99105

100106

101107
export uint TestGetDimensions() {

clang/test/CodeGenHLSL/resources/TypedBuffers-methods.hlsl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,46 @@ export float TestLoad() {
3838
// CHECK-NEXT: %[[VEC:.*]] = load <4 x i32>, ptr %[[PTR]]
3939
// CHECK-NEXT: ret <4 x i32> %[[VEC]]
4040

41+
export float TestLoadWithStatus() {
42+
uint s1;
43+
uint s2;
44+
float ret = Buf.Load(1, s1) + float(RWBuf.Load(2, s2).y);
45+
ret += float(s1 + s2);
46+
return ret;
47+
}
48+
49+
// CHECK: define noundef nofpclass(nan inf) float @TestLoadWithStatus()()
50+
// CHECK: call {{.*}} float @hlsl::Buffer<float>::Load(unsigned int, unsigned int&)(ptr {{.*}} @Buf, i32 noundef 1, ptr noundef nonnull align 4 dereferenceable(4) %s1)
51+
// CHECK: call {{.*}} <4 x i32> @hlsl::RWBuffer<unsigned int vector[4]>::Load(unsigned int, unsigned int&)(ptr {{.*}} @RWBuf, i32 noundef 2, ptr noundef nonnull align 4 dereferenceable(4) %s2)
52+
// CHECK: add
53+
// CHECK: ret float
54+
55+
// CHECK: define {{.*}} float @hlsl::Buffer<float>::Load(unsigned int, unsigned int&)(ptr {{.*}} %this, i32 noundef %Index, ptr noundef nonnull align 4 dereferenceable(4) %Status)
56+
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::Buffer", ptr %{{.*}}, i32 0, i32 0
57+
// DXIL-NEXT: %[[HANDLE:.*]] = load target("dx.TypedBuffer", float, 0, 0, 0), ptr %__handle
58+
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
59+
// CHECK-NEXT: %[[STATUS:.*]] = load ptr, ptr %Status.addr,
60+
// DXIL-NEXT: %[[STRUCT:.*]] = call { ptr, i1 } @llvm.dx.resource.load.typedbuffer.p0.tdx.TypedBuffer_f32_0_0_0t(target("dx.TypedBuffer", float, 0, 0, 0) %[[HANDLE]], i32 %[[INDEX]])
61+
// CHECK-NEXT: %[[VALUE:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 0
62+
// CHECK-NEXT: %[[STATUS_TEMP:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 1
63+
// CHECK-NEXT: %[[STATUS_EXT:.*]] = zext i1 %[[STATUS_TEMP]] to i32
64+
// CHECK-NEXT: store i32 %[[STATUS_EXT]], ptr %2, align 4
65+
// CHECK-NEXT: %[[RETVAL:.*]] = load float, ptr %[[VALUE]]
66+
// CHECK-NEXT: ret float %[[RETVAL]]
67+
68+
// CHECK: define {{.*}} <4 x i32> @hlsl::RWBuffer<unsigned int vector[4]>::Load(unsigned int, unsigned int&)(ptr {{.*}} %this, i32 noundef %Index, ptr noundef nonnull align 4 dereferenceable(4) %Status)
69+
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RWBuffer", ptr %{{.*}}, i32 0, i32 0
70+
// DXIL-NEXT: %[[HANDLE:.*]] = load target("dx.TypedBuffer", <4 x i32>, 1, 0, 0), ptr %__handle
71+
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
72+
// CHECK-NEXT: %[[STATUS_HANDLE:.*]] = load ptr, ptr %Status.addr, align 4, !nonnull !3, !align !4
73+
// DXIL-NEXT: %[[STRUCT:.*]] = call { ptr, i1 } @llvm.dx.resource.load.typedbuffer.p0.tdx.TypedBuffer_v4i32_1_0_0t(target("dx.TypedBuffer", <4 x i32>, 1, 0, 0) %0, i32 %1)
74+
// CHECK-NEXT: %[[VALUE:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 0
75+
// CHECK-NEXT: %[[STATUS:.*]] = extractvalue { ptr, i1 } %[[STRUCT]], 1
76+
// CHECK-NEXT: %[[STATUS_EXT:.*]] = zext i1 %[[STATUS]] to i32
77+
// CHECK-NEXT: store i32 %[[STATUS_EXT]], ptr %2, align 4
78+
// CHECK-NEXT: %[[RETVAL:.*]] = load <4 x i32>, ptr %[[VALUE]]
79+
// CHECK-NEXT: ret <4 x i32> %[[RETVAL]]
80+
4181
export uint TestGetDimensions() {
4282
uint dim1, dim2;
4383
Buf.GetDimensions(dim1);

llvm/include/llvm/IR/IntrinsicsDirectX.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def int_dx_resource_getpointer
4040
: DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_any_ty, llvm_i32_ty],
4141
[IntrNoMem]>;
4242

43-
def int_dx_resource_getpointer_with_status
43+
def int_dx_resource_load_with_status
4444
: DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_any_ty, llvm_i32_ty, llvm_i32_ty],
4545
[IntrNoMem]>;
4646

0 commit comments

Comments
 (0)