Skip to content

Commit 18ba12c

Browse files
committed
KernelProperties -> UsedOptionalFeatures
1 parent df73f90 commit 18ba12c

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

llvm/tools/sycl-post-link/ModuleSplitter.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,14 @@ getDoubleGRFSplitter(ModuleDesc &&MD, bool EmitOnlyKernelsAsEntryPoints) {
762762
}
763763

764764
namespace {
765-
struct KernelProperties {
766-
KernelProperties() = default;
767-
768-
KernelProperties(const Function *F) {
765+
// Data structure, which represent a combination of all possible optional
766+
// features used in a function.
767+
//
768+
// It has extra methods to be useable as a key in llvm::DenseMap.
769+
struct UsedOptionalFeatures {
770+
UsedOptionalFeatures() = default;
771+
772+
UsedOptionalFeatures(const Function *F) {
769773
if (const MDNode *MDN = F->getMetadata("sycl_used_aspects")) {
770774
auto ExtractIntegerFromMDNodeOperand = [=](const MDNode *N,
771775
unsigned OpNo) -> auto {
@@ -796,14 +800,14 @@ namespace {
796800
// TODO: extend this further with reqd-sub-group-size, reqd-work-group-size,
797801
// double-grf and other properties
798802

799-
static KernelProperties getTombstone() {
800-
KernelProperties Ret;
803+
static UsedOptionalFeatures getTombstone() {
804+
UsedOptionalFeatures Ret;
801805
Ret.IsTombstoneKey = true;
802806
return Ret;
803807
}
804808

805-
static KernelProperties getEmpty() {
806-
KernelProperties Ret;
809+
static UsedOptionalFeatures getEmpty() {
810+
UsedOptionalFeatures Ret;
807811
Ret.IsEmpty = true;
808812
return Ret;
809813
}
@@ -814,7 +818,7 @@ namespace {
814818
bool IsEmpty = false;
815819

816820
public:
817-
bool operator==(const KernelProperties &Other) const {
821+
bool operator==(const UsedOptionalFeatures &Other) const {
818822
// Tombstone does not compare equal to any other item
819823
if (IsTombstoneKey || Other.IsTombstoneKey)
820824
return false;
@@ -836,21 +840,21 @@ namespace {
836840
}
837841
};
838842

839-
struct KernelPropertiesAsKeyInfo {
840-
static inline KernelProperties getEmptyKey() {
841-
return KernelProperties::getEmpty();
843+
struct UsedOptionalFeaturesAsKeyInfo {
844+
static inline UsedOptionalFeatures getEmptyKey() {
845+
return UsedOptionalFeatures::getEmpty();
842846
}
843847

844-
static inline KernelProperties getTombstoneKey() {
845-
return KernelProperties::getTombstone();
848+
static inline UsedOptionalFeatures getTombstoneKey() {
849+
return UsedOptionalFeatures::getTombstone();
846850
}
847851

848-
static unsigned getHashValue(const KernelProperties &Value) {
852+
static unsigned getHashValue(const UsedOptionalFeatures &Value) {
849853
return Value.hash();
850854
}
851855

852-
static bool isEqual(const KernelProperties &LHS,
853-
const KernelProperties &RHS) {
856+
static bool isEqual(const UsedOptionalFeatures &LHS,
857+
const UsedOptionalFeatures &RHS) {
854858
return LHS == RHS;
855859
}
856860
};
@@ -860,7 +864,7 @@ std::unique_ptr<ModuleSplitterBase>
860864
getPropertiesBasedSplitter(ModuleDesc &&MD, bool EmitOnlyKernelsAsEntryPoints) {
861865
EntryPointGroupVec Groups;
862866

863-
DenseMap<KernelProperties, EntryPointSet, KernelPropertiesAsKeyInfo>
867+
DenseMap<UsedOptionalFeatures, EntryPointSet, UsedOptionalFeaturesAsKeyInfo>
864868
PropertiesToFunctionsMap;
865869

866870
Module &M = MD.getModule();
@@ -872,7 +876,7 @@ getPropertiesBasedSplitter(ModuleDesc &&MD, bool EmitOnlyKernelsAsEntryPoints) {
872876
continue;
873877
}
874878

875-
auto Key = KernelProperties(&F);
879+
auto Key = UsedOptionalFeatures(&F);
876880
PropertiesToFunctionsMap[Key].insert(&F);
877881
}
878882

0 commit comments

Comments
 (0)