Skip to content

[Sema] NFC: Expand TypeVar ID/GraphIndex to 32 bits #25818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,14 @@ class alignas(1 << TypeAlignInBits) TypeBase {
NumProtocols : 16
);

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

/// Type variable options.
Options : 4,

/// Index into the list of type variables, as used by the
/// constraint graph.
GraphIndex : 20
/// The unique number assigned to this type variable.
ID : 32
);

SWIFT_INLINE_BITFIELD(SILFunctionType, TypeBase, NumSILExtInfoBits+3+1+2,
Expand Down
8 changes: 6 additions & 2 deletions lib/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class TypeVariableType::Implementation {
/// The corresponding node in the constraint graph.
constraints::ConstraintGraphNode *GraphNode = nullptr;

/// Index into the list of type variables, as used by the
/// constraint graph.
unsigned GraphIndex;

friend class constraints::SavedTypeVariableBinding;

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

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

/// Check whether this type variable either has a representative that
Expand Down