@@ -28,6 +28,11 @@ enum class KnownProtocolKind : uint8_t {
2828#include " swift/AST/KnownProtocols.def"
2929};
3030
31+ enum class RepressibleProtocolKind : uint8_t {
32+ #define REPRESSIBLE_PROTOCOL_WITH_NAME (Id, Name ) Id,
33+ #include " swift/AST/KnownProtocols.def"
34+ };
35+
3136enum : uint8_t {
3237 // This uses a preprocessor trick to count all the protocols. The enum value
3338 // expression below expands to "+1+1+1...". (Note that the first plus
@@ -44,6 +49,14 @@ enum : unsigned { NumKnownProtocolKindBits =
4449// / Retrieve the name of the given known protocol.
4550llvm::StringRef getProtocolName (KnownProtocolKind kind);
4651
52+ std::optional<RepressibleProtocolKind>
53+ getRepressibleProtocolKind (KnownProtocolKind kp);
54+
55+ KnownProtocolKind getKnownProtocolKind (RepressibleProtocolKind ip);
56+
57+ void simple_display (llvm::raw_ostream &out,
58+ const RepressibleProtocolKind &value);
59+
4760// / MARK: Invertible protocols
4861// /
4962// / The invertible protocols are a subset of the known protocols.
@@ -71,4 +84,27 @@ void simple_display(llvm::raw_ostream &out,
7184
7285} // end namespace swift
7386
87+ namespace llvm {
88+ template <typename T, typename Enable>
89+ struct DenseMapInfo ;
90+ template <>
91+ struct DenseMapInfo <swift::RepressibleProtocolKind> {
92+ using RepressibleProtocolKind = swift::RepressibleProtocolKind;
93+ using Impl = DenseMapInfo<uint8_t >;
94+ static inline RepressibleProtocolKind getEmptyKey () {
95+ return (RepressibleProtocolKind)Impl::getEmptyKey ();
96+ }
97+ static inline RepressibleProtocolKind getTombstoneKey () {
98+ return (RepressibleProtocolKind)Impl::getTombstoneKey ();
99+ }
100+ static unsigned getHashValue (const RepressibleProtocolKind &Val) {
101+ return Impl::getHashValue ((uint8_t )Val);
102+ }
103+ static bool isEqual (const RepressibleProtocolKind &LHS,
104+ const RepressibleProtocolKind &RHS) {
105+ return LHS == RHS;
106+ }
107+ };
108+ } // namespace llvm
109+
74110#endif
0 commit comments