Skip to content

Commit 3e59cc4

Browse files
authored
Merge pull request #32646 from davezarzycki/pr32646
[AST] Stop using PointerIntPair for SIL params/results
2 parents 46a315e + 3f18b5e commit 3e59cc4

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

include/swift/AST/Types.h

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,7 +3640,7 @@ inline CanGenericSignature CanAnyFunctionType::getOptGenericSignature() const {
36403640
}
36413641

36423642
/// Conventions for passing arguments as parameters.
3643-
enum class ParameterConvention {
3643+
enum class ParameterConvention : uint8_t {
36443644
/// This argument is passed indirectly, i.e. by directly passing the address
36453645
/// of an object in memory. The callee is responsible for destroying the
36463646
/// object. The callee may assume that the address does not alias any valid
@@ -3686,7 +3686,7 @@ enum class ParameterConvention {
36863686
};
36873687
// Check that the enum values fit inside Bits.SILFunctionType.
36883688
static_assert(unsigned(ParameterConvention::Direct_Guaranteed) < (1<<3),
3689-
"fits in Bits.SILFunctionType and SILParameterInfo");
3689+
"fits in Bits.SILFunctionType");
36903690

36913691
// Does this parameter convention require indirect storage? This reflects a
36923692
// SILFunctionType's formal (immutable) conventions, as opposed to the transient
@@ -3745,7 +3745,7 @@ inline bool isGuaranteedParameter(ParameterConvention conv) {
37453745
}
37463746

37473747
/// The differentiability of a SIL function type parameter.
3748-
enum class SILParameterDifferentiability : unsigned {
3748+
enum class SILParameterDifferentiability : bool {
37493749
/// Either differentiable or not applicable.
37503750
///
37513751
/// - If the function type is not `@differentiable`, parameter
@@ -3763,16 +3763,17 @@ enum class SILParameterDifferentiability : unsigned {
37633763

37643764
/// A parameter type and the rules for passing it.
37653765
class SILParameterInfo {
3766-
llvm::PointerIntPair<CanType, 3, ParameterConvention> TypeAndConvention;
3767-
SILParameterDifferentiability Differentiability : 1;
3766+
CanType Type;
3767+
ParameterConvention Convention;
3768+
SILParameterDifferentiability Differentiability;
37683769

37693770
public:
37703771
SILParameterInfo() = default;//: Ty(), Convention((ParameterConvention)0) {}
37713772
SILParameterInfo(
37723773
CanType type, ParameterConvention conv,
37733774
SILParameterDifferentiability differentiability =
37743775
SILParameterDifferentiability::DifferentiableOrNotApplicable)
3775-
: TypeAndConvention(type, conv), Differentiability(differentiability) {
3776+
: Type(type), Convention(conv), Differentiability(differentiability) {
37763777
assert(type->isLegalSILType() && "SILParameterInfo has illegal SIL type");
37773778
}
37783779

@@ -3781,15 +3782,15 @@ class SILParameterInfo {
37813782
///
37823783
/// For most purposes, you probably want \c getArgumentType .
37833784
CanType getInterfaceType() const {
3784-
return TypeAndConvention.getPointer();
3785+
return Type;
37853786
}
37863787

37873788
/// Return the type of a call argument matching this parameter.
37883789
///
37893790
/// \c t must refer back to the function type this is a parameter for.
37903791
CanType getArgumentType(SILModule &M, const SILFunctionType *t, TypeExpansionContext context) const;
37913792
ParameterConvention getConvention() const {
3792-
return TypeAndConvention.getInt();
3793+
return Convention;
37933794
}
37943795
// Does this parameter convention require indirect storage? This reflects a
37953796
// SILFunctionType's formal (immutable) conventions, as opposed to the
@@ -3908,7 +3909,7 @@ class SILParameterInfo {
39083909
};
39093910

39103911
/// Conventions for returning values.
3911-
enum class ResultConvention {
3912+
enum class ResultConvention : uint8_t {
39123913
/// This result is returned indirectly, i.e. by passing the address
39133914
/// of an uninitialized object in memory. The callee is responsible
39143915
/// for leaving an initialized object at this address. The callee
@@ -3943,7 +3944,7 @@ inline bool isIndirectFormalResult(ResultConvention convention) {
39433944
}
39443945

39453946
/// The differentiability of a SIL function type result.
3946-
enum class SILResultDifferentiability : unsigned {
3947+
enum class SILResultDifferentiability : bool {
39473948
/// Either differentiable or not applicable.
39483949
///
39493950
/// - If the function type is not `@differentiable`, result
@@ -3961,15 +3962,16 @@ enum class SILResultDifferentiability : unsigned {
39613962

39623963
/// A result type and the rules for returning it.
39633964
class SILResultInfo {
3964-
llvm::PointerIntPair<CanType, 3, ResultConvention> TypeAndConvention;
3965-
SILResultDifferentiability Differentiability : 1;
3965+
CanType Type;
3966+
ResultConvention Convention;
3967+
SILResultDifferentiability Differentiability;
39663968

39673969
public:
39683970
SILResultInfo() = default;
39693971
SILResultInfo(CanType type, ResultConvention conv,
39703972
SILResultDifferentiability differentiability =
39713973
SILResultDifferentiability::DifferentiableOrNotApplicable)
3972-
: TypeAndConvention(type, conv), Differentiability(differentiability) {
3974+
: Type(type), Convention(conv), Differentiability(differentiability) {
39733975
assert(type->isLegalSILType() && "SILResultInfo has illegal SIL type");
39743976
}
39753977

@@ -3978,7 +3980,7 @@ class SILResultInfo {
39783980
///
39793981
/// For most purposes, you probably want \c getReturnValueType .
39803982
CanType getInterfaceType() const {
3981-
return TypeAndConvention.getPointer();
3983+
return Type;
39823984
}
39833985

39843986
/// The type of a return value corresponding to this result.
@@ -3988,7 +3990,7 @@ class SILResultInfo {
39883990
TypeExpansionContext context) const;
39893991

39903992
ResultConvention getConvention() const {
3991-
return TypeAndConvention.getInt();
3993+
return Convention;
39923994
}
39933995

39943996
SILResultDifferentiability getDifferentiability() const {
@@ -4056,8 +4058,9 @@ class SILResultInfo {
40564058
}
40574059

40584060
void profile(llvm::FoldingSetNodeID &id) {
4059-
id.AddPointer(TypeAndConvention.getOpaqueValue());
4060-
id.AddInteger((unsigned)getDifferentiability());
4061+
id.AddPointer(Type.getPointer());
4062+
id.AddInteger(unsigned(getConvention()));
4063+
id.AddInteger(unsigned(getDifferentiability()));
40614064
}
40624065

40634066
SWIFT_DEBUG_DUMP;
@@ -4074,7 +4077,8 @@ class SILResultInfo {
40744077
getOwnershipKind(SILFunction &, CanSILFunctionType fTy) const; // in SILType.cpp
40754078

40764079
bool operator==(SILResultInfo rhs) const {
4077-
return TypeAndConvention == rhs.TypeAndConvention;
4080+
return Type == rhs.Type && Convention == rhs.Convention
4081+
&& Differentiability == rhs.Differentiability;
40784082
}
40794083
bool operator!=(SILResultInfo rhs) const {
40804084
return !(*this == rhs);

0 commit comments

Comments
 (0)