1414// includes target-independent information which can be usefully shared
1515// between them.
1616//
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+ //
1721// ===----------------------------------------------------------------------===//
1822
1923#ifndef SWIFT_ABI_METADATAVALUES_H
2024#define SWIFT_ABI_METADATAVALUES_H
2125
2226#include " swift/ABI/KeyPath.h"
2327#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?
2431#include " swift/AST/Ownership.h"
32+
2533#include " swift/Basic/Debug.h"
2634#include " swift/Basic/LLVM.h"
2735#include " swift/Basic/FlagSet.h"
@@ -1248,10 +1256,25 @@ class TargetExtendedFunctionTypeFlags {
12481256};
12491257using ExtendedFunctionTypeFlags = TargetExtendedFunctionTypeFlags<uint32_t >;
12501258
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+
12511274template <typename int_type>
12521275class TargetParameterTypeFlags {
12531276 enum : int_type {
1254- ValueOwnershipMask = 0x7F ,
1277+ OwnershipMask = 0x7F ,
12551278 VariadicMask = 0x80 ,
12561279 AutoClosureMask = 0x100 ,
12571280 NoDerivativeMask = 0x200 ,
@@ -1266,8 +1289,8 @@ class TargetParameterTypeFlags {
12661289 constexpr TargetParameterTypeFlags () : Data(0 ) {}
12671290
12681291 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 ) |
12711294 (int_type)ownership);
12721295 }
12731296
@@ -1308,8 +1331,8 @@ class TargetParameterTypeFlags {
13081331 bool isIsolated () const { return Data & IsolatedMask; }
13091332 bool isTransferring () const { return Data & TransferringMask; }
13101333
1311- ValueOwnership getValueOwnership () const {
1312- return (ValueOwnership )(Data & ValueOwnershipMask );
1334+ ParameterOwnership getOwnership () const {
1335+ return (ParameterOwnership )(Data & OwnershipMask );
13131336 }
13141337
13151338 int_type getIntValue () const { return Data; }
0 commit comments