14
14
// includes target-independent information which can be usefully shared
15
15
// between them.
16
16
//
17
+ // This header ought not to include any compiler-specific headers (such as
18
+ // those from `swift/AST`, `swift/SIL`, etc.) since doing so may introduce
19
+ // accidental ABI dependencies on compiler internals.
20
+ //
17
21
// ===----------------------------------------------------------------------===//
18
22
19
23
#ifndef SWIFT_ABI_METADATAVALUES_H
20
24
#define SWIFT_ABI_METADATAVALUES_H
21
25
22
26
#include " swift/ABI/KeyPath.h"
23
27
#include " swift/ABI/ProtocolDispatchStrategy.h"
28
+
29
+ // FIXME: this include shouldn't be here, but removing it causes symbol
30
+ // mangling mismatches on Windows for some reason?
24
31
#include " swift/AST/Ownership.h"
32
+
25
33
#include " swift/Basic/Debug.h"
26
34
#include " swift/Basic/LLVM.h"
27
35
#include " swift/Basic/FlagSet.h"
@@ -1248,10 +1256,25 @@ class TargetExtendedFunctionTypeFlags {
1248
1256
};
1249
1257
using ExtendedFunctionTypeFlags = TargetExtendedFunctionTypeFlags<uint32_t >;
1250
1258
1259
+ // / Different kinds of value ownership supported by function types.
1260
+ enum class ParameterOwnership : uint8_t {
1261
+ // / the context-dependent default ownership (sometimes shared,
1262
+ // / sometimes owned)
1263
+ Default,
1264
+ // / an 'inout' exclusive, mutating borrow
1265
+ InOut,
1266
+ // / a 'borrowing' nonexclusive, usually nonmutating borrow
1267
+ Shared,
1268
+ // / a 'consuming' ownership transfer
1269
+ Owned,
1270
+
1271
+ Last_Kind = Owned
1272
+ };
1273
+
1251
1274
template <typename int_type>
1252
1275
class TargetParameterTypeFlags {
1253
1276
enum : int_type {
1254
- ValueOwnershipMask = 0x7F ,
1277
+ OwnershipMask = 0x7F ,
1255
1278
VariadicMask = 0x80 ,
1256
1279
AutoClosureMask = 0x100 ,
1257
1280
NoDerivativeMask = 0x200 ,
@@ -1266,8 +1289,8 @@ class TargetParameterTypeFlags {
1266
1289
constexpr TargetParameterTypeFlags () : Data(0 ) {}
1267
1290
1268
1291
constexpr TargetParameterTypeFlags<int_type>
1269
- withValueOwnership (ValueOwnership ownership) const {
1270
- return TargetParameterTypeFlags<int_type>((Data & ~ValueOwnershipMask ) |
1292
+ withOwnership (ParameterOwnership ownership) const {
1293
+ return TargetParameterTypeFlags<int_type>((Data & ~OwnershipMask ) |
1271
1294
(int_type)ownership);
1272
1295
}
1273
1296
@@ -1308,8 +1331,8 @@ class TargetParameterTypeFlags {
1308
1331
bool isIsolated () const { return Data & IsolatedMask; }
1309
1332
bool isTransferring () const { return Data & TransferringMask; }
1310
1333
1311
- ValueOwnership getValueOwnership () const {
1312
- return (ValueOwnership )(Data & ValueOwnershipMask );
1334
+ ParameterOwnership getOwnership () const {
1335
+ return (ParameterOwnership )(Data & OwnershipMask );
1313
1336
}
1314
1337
1315
1338
int_type getIntValue () const { return Data; }
0 commit comments