@@ -1061,20 +1061,28 @@ class SILBuilder {
10611061 getSILDebugLocation (Loc), ArgumentsSpecification, getModule ()));
10621062 }
10631063
1064- #define NEVER_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1065- Load##Name##Inst *createLoad##Name(SILLocation Loc, \
1066- SILValue src, \
1067- IsTake_t isTake) { \
1068- return insert (new (getModule ()) \
1069- Load##Name##Inst (getSILDebugLocation (Loc), src, isTake)); \
1070- } \
1071- Store##Name##Inst *createStore##Name(SILLocation Loc, \
1072- SILValue value, \
1073- SILValue dest, \
1074- IsInitialization_t isInit) { \
1075- return insert (new (getModule ()) \
1076- Store##Name##Inst (getSILDebugLocation (Loc), value, dest, isInit)); \
1064+ #define COPYABLE_STORAGE_HELPER (Name ) \
1065+ StrongCopy##Name##ValueInst *createStrongCopy##Name##Value( \
1066+ SILLocation Loc, SILValue operand) { \
1067+ auto type = getFunction ().getLoweredType ( \
1068+ operand->getType ().getASTType ().getReferenceStorageReferent ()); \
1069+ return insert (new (getModule ()) StrongCopy##Name##ValueInst ( \
1070+ getSILDebugLocation (Loc), operand, type)); \
10771071 }
1072+
1073+ #define LOADABLE_STORAGE_HELPER (Name ) \
1074+ Load##Name##Inst *createLoad##Name(SILLocation Loc, SILValue src, \
1075+ IsTake_t isTake) { \
1076+ return insert (new (getModule ()) Load##Name##Inst (getSILDebugLocation (Loc), \
1077+ src, isTake)); \
1078+ } \
1079+ Store##Name##Inst *createStore##Name(SILLocation Loc, SILValue value, \
1080+ SILValue dest, \
1081+ IsInitialization_t isInit) { \
1082+ return insert (new (getModule ()) Store##Name##Inst ( \
1083+ getSILDebugLocation (Loc), value, dest, isInit)); \
1084+ }
1085+
10781086#define LOADABLE_REF_STORAGE_HELPER (Name ) \
10791087 Name##ToRefInst *create##Name##ToRef(SILLocation Loc, SILValue op, \
10801088 SILType ty) { \
@@ -1085,41 +1093,45 @@ class SILBuilder {
10851093 SILType ty) { \
10861094 return insert (new (getModule ()) \
10871095 RefTo##Name##Inst (getSILDebugLocation (Loc), op, ty)); \
1088- } \
1089- StrongCopy##Name##ValueInst *createStrongCopy##Name##Value( \
1090- SILLocation Loc, SILValue operand) { \
1091- auto type = getFunction ().getLoweredType ( \
1092- operand->getType ().getASTType ().getReferenceStorageReferent ()); \
1093- return insert (new (getModule ()) StrongCopy##Name##ValueInst ( \
1094- getSILDebugLocation (Loc), operand, type)); \
10951096 }
10961097
1097- #define ALWAYS_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1098- LOADABLE_REF_STORAGE_HELPER (Name) \
1099- StrongRetain##Name##Inst *createStrongRetain##Name(SILLocation Loc, \
1100- SILValue Operand, \
1101- Atomicity atomicity) { \
1102- return insert (new (getModule ()) \
1103- StrongRetain##Name##Inst (getSILDebugLocation (Loc), Operand, atomicity)); \
1104- } \
1105- Name##RetainInst *create##Name##Retain(SILLocation Loc, SILValue Operand, \
1106- Atomicity atomicity) { \
1107- return insert (new (getModule ()) \
1108- Name##RetainInst (getSILDebugLocation (Loc), Operand, atomicity)); \
1109- } \
1110- Name##ReleaseInst *create##Name##Release(SILLocation Loc, \
1111- SILValue Operand, \
1112- Atomicity atomicity) { \
1113- return insert (new (getModule ()) \
1114- Name##ReleaseInst (getSILDebugLocation (Loc), Operand, atomicity)); \
1115- }
1116- #define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1117- NEVER_LOADABLE_CHECKED_REF_STORAGE (Name, " ..." ) \
1118- ALWAYS_LOADABLE_CHECKED_REF_STORAGE(Name, " ..." )
1119- #define UNCHECKED_REF_STORAGE (Name, ...) \
1098+ #define RETAINABLE_STORAGE_HELPER (Name ) \
1099+ StrongRetain##Name##Inst *createStrongRetain##Name( \
1100+ SILLocation Loc, SILValue Operand, Atomicity atomicity) { \
1101+ return insert (new (getModule ()) StrongRetain##Name##Inst ( \
1102+ getSILDebugLocation (Loc), Operand, atomicity)); \
1103+ } \
1104+ Name##RetainInst *create##Name##Retain(SILLocation Loc, SILValue Operand, \
1105+ Atomicity atomicity) { \
1106+ return insert (new (getModule ()) Name##RetainInst (getSILDebugLocation (Loc), \
1107+ Operand, atomicity)); \
1108+ } \
1109+ Name##ReleaseInst *create##Name##Release(SILLocation Loc, SILValue Operand, \
1110+ Atomicity atomicity) { \
1111+ return insert (new (getModule ()) Name##ReleaseInst ( \
1112+ getSILDebugLocation (Loc), Operand, atomicity)); \
1113+ }
1114+
1115+ #define ALWAYS_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1116+ COPYABLE_STORAGE_HELPER (Name) \
1117+ LOADABLE_REF_STORAGE_HELPER(Name) \
1118+ RETAINABLE_STORAGE_HELPER(Name)
1119+ #define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1120+ COPYABLE_STORAGE_HELPER (Name) \
1121+ LOADABLE_REF_STORAGE_HELPER(Name) \
1122+ LOADABLE_STORAGE_HELPER(Name) \
1123+ RETAINABLE_STORAGE_HELPER(Name)
1124+ #define NEVER_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1125+ COPYABLE_STORAGE_HELPER (Name) \
1126+ LOADABLE_STORAGE_HELPER(Name)
1127+ #define UNCHECKED_REF_STORAGE (Name, ...) \
1128+ COPYABLE_STORAGE_HELPER (Name) \
11201129 LOADABLE_REF_STORAGE_HELPER(Name)
11211130#include " swift/AST/ReferenceStorage.def"
1131+ #undef LOADABLE_STORAGE_HELPER
11221132#undef LOADABLE_REF_STORAGE_HELPER
1133+ #undef COPYABLE_STORAGE_HELPER
1134+ #undef RETAINABLE_STORAGE_HELPER
11231135
11241136 CopyAddrInst *createCopyAddr (SILLocation Loc, SILValue srcAddr,
11251137 SILValue destAddr, IsTake_t isTake,
0 commit comments