Skip to content

Commit 18f0da2

Browse files
committed
[HLSL][DirectX] Avoid some unnecessary casting. NFC
1 parent 3791b3f commit 18f0da2

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

llvm/include/llvm/Frontend/HLSL/HLSLResource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class FrontendResource {
6767

6868
GlobalVariable *getGlobalVariable();
6969
StringRef getSourceType();
70-
uint32_t getResourceKind();
70+
ResourceKind getResourceKind();
7171
uint32_t getResourceIndex();
7272
uint32_t getSpace();
7373
MDNode *getMetadata() { return Entry; }

llvm/lib/Frontend/HLSL/HLSLResource.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ StringRef FrontendResource::getSourceType() {
2727
return cast<MDString>(Entry->getOperand(1))->getString();
2828
}
2929

30-
uint32_t FrontendResource::FrontendResource::getResourceKind() {
31-
return cast<ConstantInt>(
32-
cast<ConstantAsMetadata>(Entry->getOperand(2))->getValue())
33-
->getLimitedValue();
30+
ResourceKind FrontendResource::getResourceKind() {
31+
return static_cast<ResourceKind>(
32+
cast<ConstantInt>(
33+
cast<ConstantAsMetadata>(Entry->getOperand(2))->getValue())
34+
->getLimitedValue());
3435
}
3536
uint32_t FrontendResource::getResourceIndex() {
3637
return cast<ConstantInt>(

llvm/lib/Target/DirectX/DXILResource.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,8 @@ void ResourceBase::print(raw_ostream &OS, StringRef IDPrefix,
233233
}
234234

235235
UAVResource::UAVResource(uint32_t I, FrontendResource R)
236-
: ResourceBase(I, R),
237-
Shape(static_cast<ResourceBase::Kinds>(R.getResourceKind())),
238-
GloballyCoherent(false), HasCounter(false), IsROV(false), ExtProps() {
236+
: ResourceBase(I, R), Shape(R.getResourceKind()), GloballyCoherent(false),
237+
HasCounter(false), IsROV(false), ExtProps() {
239238
parseSourceType(R.getSourceType());
240239
}
241240

0 commit comments

Comments
 (0)