@@ -1061,20 +1061,38 @@ class SILBuilder {
1061
1061
getSILDebugLocation (Loc), ArgumentsSpecification, getModule ()));
1062
1062
}
1063
1063
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
+ WeakCopyValueInst *createWeakCopyValue (SILLocation Loc, SILValue operand) {
1065
+ assert (!getFunction ().getModule ().useLoweredAddresses ());
1066
+ auto type = operand->getType ()
1067
+ .getReferenceStorageType (getFunction ().getASTContext (),
1068
+ ReferenceOwnership::Weak)
1069
+ .getObjectType ();
1070
+ return insert (new (getModule ()) WeakCopyValueInst (getSILDebugLocation (Loc),
1071
+ operand, type));
1077
1072
}
1073
+
1074
+ #define COPYABLE_STORAGE_HELPER (Name ) \
1075
+ StrongCopy##Name##ValueInst *createStrongCopy##Name##Value( \
1076
+ SILLocation Loc, SILValue operand) { \
1077
+ auto type = getFunction ().getLoweredType ( \
1078
+ operand->getType ().getASTType ().getReferenceStorageReferent ()); \
1079
+ return insert (new (getModule ()) StrongCopy##Name##ValueInst ( \
1080
+ getSILDebugLocation (Loc), operand, type)); \
1081
+ }
1082
+
1083
+ #define LOADABLE_STORAGE_HELPER (Name ) \
1084
+ Load##Name##Inst *createLoad##Name(SILLocation Loc, SILValue src, \
1085
+ IsTake_t isTake) { \
1086
+ return insert (new (getModule ()) Load##Name##Inst (getSILDebugLocation (Loc), \
1087
+ src, isTake)); \
1088
+ } \
1089
+ Store##Name##Inst *createStore##Name(SILLocation Loc, SILValue value, \
1090
+ SILValue dest, \
1091
+ IsInitialization_t isInit) { \
1092
+ return insert (new (getModule ()) Store##Name##Inst ( \
1093
+ getSILDebugLocation (Loc), value, dest, isInit)); \
1094
+ }
1095
+
1078
1096
#define LOADABLE_REF_STORAGE_HELPER (Name ) \
1079
1097
Name##ToRefInst *create##Name##ToRef(SILLocation Loc, SILValue op, \
1080
1098
SILType ty) { \
@@ -1085,41 +1103,45 @@ class SILBuilder {
1085
1103
SILType ty) { \
1086
1104
return insert (new (getModule ()) \
1087
1105
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)); \
1095
1106
}
1096
1107
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, ...) \
1108
+ #define RETAINABLE_STORAGE_HELPER (Name ) \
1109
+ StrongRetain##Name##Inst *createStrongRetain##Name( \
1110
+ SILLocation Loc, SILValue Operand, Atomicity atomicity) { \
1111
+ return insert (new (getModule ()) StrongRetain##Name##Inst ( \
1112
+ getSILDebugLocation (Loc), Operand, atomicity)); \
1113
+ } \
1114
+ Name##RetainInst *create##Name##Retain(SILLocation Loc, SILValue Operand, \
1115
+ Atomicity atomicity) { \
1116
+ return insert (new (getModule ()) Name##RetainInst (getSILDebugLocation (Loc), \
1117
+ Operand, atomicity)); \
1118
+ } \
1119
+ Name##ReleaseInst *create##Name##Release(SILLocation Loc, SILValue Operand, \
1120
+ Atomicity atomicity) { \
1121
+ return insert (new (getModule ()) Name##ReleaseInst ( \
1122
+ getSILDebugLocation (Loc), Operand, atomicity)); \
1123
+ }
1124
+
1125
+ #define ALWAYS_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1126
+ COPYABLE_STORAGE_HELPER (Name) \
1127
+ LOADABLE_REF_STORAGE_HELPER(Name) \
1128
+ RETAINABLE_STORAGE_HELPER(Name)
1129
+ #define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1130
+ COPYABLE_STORAGE_HELPER (Name) \
1131
+ LOADABLE_REF_STORAGE_HELPER(Name) \
1132
+ LOADABLE_STORAGE_HELPER(Name) \
1133
+ RETAINABLE_STORAGE_HELPER(Name)
1134
+ #define NEVER_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
1135
+ COPYABLE_STORAGE_HELPER (Name) \
1136
+ LOADABLE_STORAGE_HELPER(Name)
1137
+ #define UNCHECKED_REF_STORAGE (Name, ...) \
1138
+ COPYABLE_STORAGE_HELPER (Name) \
1120
1139
LOADABLE_REF_STORAGE_HELPER(Name)
1121
1140
#include " swift/AST/ReferenceStorage.def"
1141
+ #undef LOADABLE_STORAGE_HELPER
1122
1142
#undef LOADABLE_REF_STORAGE_HELPER
1143
+ #undef COPYABLE_STORAGE_HELPER
1144
+ #undef RETAINABLE_STORAGE_HELPER
1123
1145
1124
1146
CopyAddrInst *createCopyAddr (SILLocation Loc, SILValue srcAddr,
1125
1147
SILValue destAddr, IsTake_t isTake,
0 commit comments