Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 0 additions & 3 deletions llvm/include/llvm/Support/DXILABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define LLVM_SUPPORT_DXILABI_H

#include "llvm/ADT/StringRef.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also replace this StringRef.h include with a forward declaration.

#include "llvm/Support/ScopedPrinter.h"
#include <cstdint>

namespace llvm {
Expand Down Expand Up @@ -101,8 +100,6 @@ enum class SamplerFeedbackType : uint32_t {
const unsigned MinWaveSize = 4;
const unsigned MaxWaveSize = 128;

LLVM_ABI ArrayRef<EnumEntry<ResourceClass>> getResourceClasses();

LLVM_ABI StringRef getResourceClassName(ResourceClass RC);

} // namespace dxil
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/ScopedPrinter.h"

namespace llvm {
Expand Down Expand Up @@ -93,9 +94,7 @@ static raw_ostream &operator<<(raw_ostream &OS,
}

static raw_ostream &operator<<(raw_ostream &OS, const ClauseType &Type) {
OS << enumToStringRef(dxil::ResourceClass(llvm::to_underlying(Type)),
dxil::getResourceClasses());

OS << dxil::getResourceClassName(dxil::ResourceClass(Type));
return OS;
}

Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ MDNode *MetadataBuilder::BuildRootConstants(const RootConstants &Constants) {
MDNode *MetadataBuilder::BuildRootDescriptor(const RootDescriptor &Descriptor) {
IRBuilder<> Builder(Ctx);
StringRef ResName =
enumToStringRef(dxil::ResourceClass(to_underlying(Descriptor.Type)),
dxil::getResourceClasses());
dxil::getResourceClassName(dxil::ResourceClass(Descriptor.Type));
assert(!ResName.empty() && "Provided an invalid Resource Class");
SmallString<7> Name({"Root", ResName});
Metadata *Operands[] = {
Expand Down Expand Up @@ -162,8 +161,7 @@ MDNode *MetadataBuilder::BuildDescriptorTableClause(
const DescriptorTableClause &Clause) {
IRBuilder<> Builder(Ctx);
StringRef ResName =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the same enum @llvm-beanz

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using ClauseType = llvm::dxil::ResourceClass;

enumToStringRef(dxil::ResourceClass(to_underlying(Clause.Type)),
dxil::getResourceClasses());
dxil::getResourceClassName(dxil::ResourceClass(Clause.Type));
assert(!ResName.empty() && "Provided an invalid Resource Class");
Metadata *Operands[] = {
MDString::get(Ctx, ResName),
Expand Down
25 changes: 12 additions & 13 deletions llvm/lib/Support/DXILABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
//===----------------------------------------------------------------------===//

#include "llvm/Support/DXILABI.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;

static const EnumEntry<dxil::ResourceClass> ResourceClassNames[] = {
{"SRV", llvm::dxil::ResourceClass::SRV},
{"UAV", llvm::dxil::ResourceClass::UAV},
{"CBV", llvm::dxil::ResourceClass::CBuffer},
{"Sampler", llvm::dxil::ResourceClass::Sampler},
};

ArrayRef<EnumEntry<llvm::dxil::ResourceClass>> dxil::getResourceClasses() {
return ArrayRef(ResourceClassNames);
}

StringRef dxil::getResourceClassName(dxil::ResourceClass RC) {
return enumToStringRef(RC, getResourceClasses());
switch (RC) {
case dxil::ResourceClass::SRV:
return "SRV";
case dxil::ResourceClass::UAV:
return "UAV";
case dxil::ResourceClass::CBuffer:
return "CBV";
case dxil::ResourceClass::Sampler:
return "Sampler";
}
llvm_unreachable("Invalid ResourceClass enum value");
}
Loading