Skip to content

Commit ed55ef2

Browse files
authored
Merge pull request #30490 from atrick/add-apply-pointer-traits
Add PointerLikeTypeTraits to ApplySite and FullApplySite.
2 parents 127266e + ff5ce95 commit ed55ef2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

include/swift/SIL/ApplySite.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,32 @@ class FullApplySite : public ApplySite {
590590

591591
namespace llvm {
592592

593+
template<>
594+
struct PointerLikeTypeTraits<swift::ApplySite> {
595+
public:
596+
static inline void *getAsVoidPointer(swift::ApplySite apply) {
597+
return (void*)apply.getInstruction();
598+
}
599+
static inline swift::ApplySite getFromVoidPointer(void *pointer) {
600+
return swift::ApplySite((swift::SILInstruction*)pointer);
601+
}
602+
enum { NumLowBitsAvailable =
603+
PointerLikeTypeTraits<swift::SILNode *>::NumLowBitsAvailable };
604+
};
605+
606+
template<>
607+
struct PointerLikeTypeTraits<swift::FullApplySite> {
608+
public:
609+
static inline void *getAsVoidPointer(swift::FullApplySite apply) {
610+
return (void*)apply.getInstruction();
611+
}
612+
static inline swift::FullApplySite getFromVoidPointer(void *pointer) {
613+
return swift::FullApplySite((swift::SILInstruction*)pointer);
614+
}
615+
enum { NumLowBitsAvailable =
616+
PointerLikeTypeTraits<swift::SILNode *>::NumLowBitsAvailable };
617+
};
618+
593619
// An ApplySite casts like a SILInstruction*.
594620
template <> struct simplify_type<const ::swift::ApplySite> {
595621
using SimpleType = ::swift::SILInstruction *;

0 commit comments

Comments
 (0)