Skip to content

Commit 260633c

Browse files
Joao SaffranJoao Saffran
authored andcommitted
address comments
1 parent 662c3a8 commit 260633c

File tree

5 files changed

+27
-41
lines changed

5 files changed

+27
-41
lines changed

llvm/include/llvm/Analysis/DXILResource.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ class DXILResourceTypeMap;
3232

3333
namespace dxil {
3434

35+
inline StringRef getResourceClassName(ResourceClass RC) {
36+
switch (RC) {
37+
case ResourceClass::SRV:
38+
return "SRV";
39+
case ResourceClass::UAV:
40+
return "UAV";
41+
case ResourceClass::CBuffer:
42+
return "CBuffer";
43+
case ResourceClass::Sampler:
44+
return "Sampler";
45+
}
46+
llvm_unreachable("Unhandled ResourceClass");
47+
}
48+
3549
// Returns the resource name from dx_resource_handlefrombinding or
3650
// dx_resource_handlefromimplicitbinding call
3751
LLVM_ABI StringRef getResourceNameFromBindingCall(CallInst *CI);

llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,26 @@ class RootSignatureBindingValidation {
153153
uint32_t InsertPos = Bindings.size();
154154
Bindings.push_back(Binding);
155155
Ranges[Type] = {InsertPos, InsertPos + 1};
156-
} else {
157-
uint32_t InsertPos = It->second.End;
158-
Bindings.insert(Bindings.begin() + InsertPos, Binding);
156+
return;
157+
}
158+
uint32_t InsertPos = It->second.End;
159+
Bindings.insert(Bindings.begin() + InsertPos, Binding);
159160

160-
It->second.End++;
161+
It->second.End++;
161162

162-
for (auto &[Type, Range] : Ranges) {
163-
if (Range.Start > InsertPos) {
164-
Range.Start++;
165-
Range.End++;
166-
}
163+
for (auto &[Type, Range] : Ranges) {
164+
if (Range.Start > InsertPos) {
165+
Range.Start++;
166+
Range.End++;
167167
}
168168
}
169169
}
170170

171171
llvm::ArrayRef<RangeInfo>
172172
getBindingsOfType(const dxil::ResourceClass &Type) const {
173173
auto It = Ranges.find(Type);
174-
if (It == Ranges.end()) {
174+
if (It == Ranges.end())
175175
return {};
176-
}
177176
return llvm::ArrayRef<RangeInfo>(Bindings.data() + It->second.Start,
178177
It->second.End - It->second.Start);
179178
}

llvm/lib/Analysis/DXILResource.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@
2929
using namespace llvm;
3030
using namespace dxil;
3131

32-
static StringRef getResourceClassName(ResourceClass RC) {
33-
switch (RC) {
34-
case ResourceClass::SRV:
35-
return "SRV";
36-
case ResourceClass::UAV:
37-
return "UAV";
38-
case ResourceClass::CBuffer:
39-
return "CBuffer";
40-
case ResourceClass::Sampler:
41-
return "Sampler";
42-
}
43-
llvm_unreachable("Unhandled ResourceClass");
44-
}
45-
4632
static StringRef getResourceKindName(ResourceKind RK) {
4733
switch (RK) {
4834
case ResourceKind::Texture1D:

llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,8 @@ findUnboundRanges(const llvm::ArrayRef<RangeInfo> &Ranges,
335335
break;
336336
}
337337
}
338-
if (!Bound) {
338+
if (!Bound)
339339
Unbounds.push_back(Range);
340-
}
341340
}
342341
return Unbounds;
343342
}

llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "DXILShaderFlags.h"
1212
#include "DirectX.h"
1313
#include "llvm/ADT/SmallString.h"
14+
#include "llvm/ADT/StringRef.h"
1415
#include "llvm/Analysis/DXILMetadataAnalysis.h"
1516
#include "llvm/Analysis/DXILResource.h"
1617
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
@@ -26,19 +27,6 @@ using namespace llvm;
2627
using namespace llvm::dxil;
2728

2829
namespace {
29-
static const char *ResourceClassToString(llvm::dxil::ResourceClass Class) {
30-
switch (Class) {
31-
case ResourceClass::SRV:
32-
return "SRV";
33-
case ResourceClass::UAV:
34-
return "UAV";
35-
case ResourceClass::CBuffer:
36-
return "CBuffer";
37-
case ResourceClass::Sampler:
38-
return "Sampler";
39-
}
40-
}
41-
4230
static ResourceClass RangeToResourceClass(uint32_t RangeType) {
4331
using namespace dxbc;
4432
switch (static_cast<DescriptorRangeType>(RangeType)) {
@@ -132,7 +120,7 @@ static void reportRegNotBound(Module &M,
132120
llvm::hlsl::rootsig::RangeInfo Unbound) {
133121
SmallString<128> Message;
134122
raw_svector_ostream OS(Message);
135-
OS << "register " << ResourceClassToString(Unbound.Class)
123+
OS << "register " << getResourceClassName(Unbound.Class)
136124
<< " (space=" << Unbound.Space << ", register=" << Unbound.LowerBound
137125
<< ")"
138126
<< " does not have a binding in the Root Signature";

0 commit comments

Comments
 (0)