-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[HLSL] Refactoring DXILABI.h to not depend on scope printer #153840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
#define LLVM_SUPPORT_DXILABI_H | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/Support/ScopedPrinter.h" | ||
#include <cstdint> | ||
|
||
namespace llvm { | ||
|
@@ -101,9 +100,8 @@ 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); | ||
LLVM_ABI StringRef getResourceClassName(uint8_t RC); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a good API to add - why would we want anything other than the strongly typed version of this function? |
||
|
||
} // namespace dxil | ||
} // namespace llvm | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -119,9 +119,7 @@ MDNode *MetadataBuilder::BuildRootConstants(const RootConstants &Constants) { | |||
|
||||
MDNode *MetadataBuilder::BuildRootDescriptor(const RootDescriptor &Descriptor) { | ||||
IRBuilder<> Builder(Ctx); | ||||
StringRef ResName = | ||||
joaosaffran marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
enumToStringRef(dxil::ResourceClass(to_underlying(Descriptor.Type)), | ||||
dxil::getResourceClasses()); | ||||
StringRef ResName = dxil::getResourceClassName(to_underlying(Descriptor.Type)); | ||||
assert(!ResName.empty() && "Provided an invalid Resource Class"); | ||||
SmallString<7> Name({"Root", ResName}); | ||||
Metadata *Operands[] = { | ||||
|
@@ -161,9 +159,7 @@ MDNode *MetadataBuilder::BuildDescriptorTable(const DescriptorTable &Table) { | |||
MDNode *MetadataBuilder::BuildDescriptorTableClause( | ||||
const DescriptorTableClause &Clause) { | ||||
IRBuilder<> Builder(Ctx); | ||||
StringRef ResName = | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not the same enum @llvm-beanz There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||
enumToStringRef(dxil::ResourceClass(to_underlying(Clause.Type)), | ||||
dxil::getResourceClasses()); | ||||
StringRef ResName = dxil::getResourceClassName(to_underlying(Clause.Type)); | ||||
assert(!ResName.empty() && "Provided an invalid Resource Class"); | ||||
Metadata *Operands[] = { | ||||
MDString::get(Ctx, ResName), | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,14 @@ static const EnumEntry<dxil::ResourceClass> ResourceClassNames[] = { | |
{"Sampler", llvm::dxil::ResourceClass::Sampler}, | ||
}; | ||
|
||
ArrayRef<EnumEntry<llvm::dxil::ResourceClass>> dxil::getResourceClasses() { | ||
ArrayRef<EnumEntry<llvm::dxil::ResourceClass>> getResourceClasses() { | ||
return ArrayRef(ResourceClassNames); | ||
} | ||
|
||
StringRef dxil::getResourceClassName(dxil::ResourceClass RC) { | ||
return enumToStringRef(RC, getResourceClasses()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using ScopedPrinter for this seems like overkill if we aren't using the |
||
|
||
StringRef dxil::getResourceClassName(uint8_t RC) { | ||
return enumToStringRef(ResourceClass(RC), getResourceClasses()); | ||
} |
There was a problem hiding this comment.
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.