Skip to content

Commit d0b221e

Browse files
committed
[Sema] NFC: Expand TypeVar ID/GraphIndex to 32 bits
Users are edging closer to the arbitrary but plausible 20-bit limit.
1 parent 89382f7 commit d0b221e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

include/swift/AST/Types.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,14 @@ class alignas(1 << TypeAlignInBits) TypeBase {
336336
NumProtocols : 16
337337
);
338338

339-
SWIFT_INLINE_BITFIELD_FULL(TypeVariableType, TypeBase, 20+4+20,
340-
/// The unique number assigned to this type variable.
341-
ID : 20,
339+
SWIFT_INLINE_BITFIELD_FULL(TypeVariableType, TypeBase, 4+32,
340+
: NumPadBits,
342341

343342
/// Type variable options.
344343
Options : 4,
345344

346-
/// Index into the list of type variables, as used by the
347-
/// constraint graph.
348-
GraphIndex : 20
345+
/// The unique number assigned to this type variable.
346+
ID : 32
349347
);
350348

351349
SWIFT_INLINE_BITFIELD(SILFunctionType, TypeBase, NumSILExtInfoBits+3+1+2,

lib/Sema/ConstraintSystem.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ class TypeVariableType::Implementation {
192192
/// The corresponding node in the constraint graph.
193193
constraints::ConstraintGraphNode *GraphNode = nullptr;
194194

195+
/// Index into the list of type variables, as used by the
196+
/// constraint graph.
197+
unsigned GraphIndex;
198+
195199
friend class constraints::SavedTypeVariableBinding;
196200

197201
public:
@@ -250,12 +254,12 @@ class TypeVariableType::Implementation {
250254
/// Retrieve the index into the constraint graph's list of type variables.
251255
unsigned getGraphIndex() const {
252256
assert(GraphNode && "Graph node isn't set");
253-
return getTypeVariable()->Bits.TypeVariableType.GraphIndex;
257+
return GraphIndex;
254258
}
255259

256260
/// Set the index into the constraint graph's list of type variables.
257261
void setGraphIndex(unsigned newIndex) {
258-
getTypeVariable()->Bits.TypeVariableType.GraphIndex = newIndex;
262+
GraphIndex = newIndex;
259263
}
260264

261265
/// Check whether this type variable either has a representative that

0 commit comments

Comments
 (0)