Skip to content

Commit 4424a7c

Browse files
authored
[NFC] Gardening. (#27581)
Remove unused known protocols (`TensorProtocol`, `TensorFlowDataTypeCompatible`) and helper functions.
1 parent 0a4018f commit 4424a7c

File tree

4 files changed

+3
-16
lines changed

4 files changed

+3
-16
lines changed

include/swift/AST/KnownProtocols.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ PROTOCOL(ElementaryFunctions)
8484
PROTOCOL(KeyPathIterable)
8585
PROTOCOL(TensorArrayProtocol)
8686
PROTOCOL(TensorGroup)
87-
PROTOCOL_(TensorFlowDataTypeCompatible)
88-
PROTOCOL(TensorProtocol)
8987
PROTOCOL(VectorProtocol)
9088
PROTOCOL(Differentiable)
9189
PROTOCOL(EuclideanDifferentiable)

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,6 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
10661066
// SWIFT_ENABLE_TENSORFLOW
10671067
case KnownProtocolKind::TensorArrayProtocol:
10681068
case KnownProtocolKind::TensorGroup:
1069-
case KnownProtocolKind::TensorFlowDataTypeCompatible:
1070-
case KnownProtocolKind::TensorProtocol:
10711069
M = getLoadedModule(Id_TensorFlow);
10721070
break;
10731071
case KnownProtocolKind::Expression:

lib/IRGen/GenMeta.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,8 +4224,6 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) {
42244224
case KnownProtocolKind::KeyPathIterable:
42254225
case KnownProtocolKind::TensorArrayProtocol:
42264226
case KnownProtocolKind::TensorGroup:
4227-
case KnownProtocolKind::TensorFlowDataTypeCompatible:
4228-
case KnownProtocolKind::TensorProtocol:
42294227
case KnownProtocolKind::VectorProtocol:
42304228
case KnownProtocolKind::Differentiable:
42314229
case KnownProtocolKind::EuclideanDifferentiable:

lib/SILOptimizer/Mandatory/Differentiation.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ static CanType joinElementTypesFromValues(SILValueRange &&range,
220220
static FuncDecl *findOperatorDeclInProtocol(DeclName operatorName,
221221
ProtocolDecl *protocol) {
222222
assert(operatorName.isOperator());
223-
// Find the operator requirement in the `VectorProtocol` protocol
224-
// declaration and cache it.
223+
// Find the operator requirement in the given protocol declaration.
225224
auto opLookup = protocol->lookupDirect(operatorName);
226-
// Find the `+` with type siguature `(Self, Self) -> Self`.
227225
for (auto *decl : opLookup) {
226+
if (!decl->isProtocolRequirement())
227+
continue;
228228
auto *fd = dyn_cast<FuncDecl>(decl);
229229
if (!fd || !fd->isStatic() || !fd->isOperator())
230230
continue;
@@ -875,9 +875,6 @@ class ADContext {
875875
/// The AdditiveArithmetic protocol in the standard library.
876876
ProtocolDecl *additiveArithmeticProtocol =
877877
astCtx.getProtocol(KnownProtocolKind::AdditiveArithmetic);
878-
/// The VectorProtocol protocol in the standard library.
879-
ProtocolDecl *vectorProtocolProtocol =
880-
astCtx.getProtocol(KnownProtocolKind::VectorProtocol);
881878

882879
/// `AdditiveArithmetic.+` declaration.
883880
mutable FuncDecl *cachedPlusFn = nullptr;
@@ -933,10 +930,6 @@ class ADContext {
933930
return additiveArithmeticProtocol;
934931
}
935932

936-
ProtocolDecl *getVectorProtocolProtocol() const {
937-
return vectorProtocolProtocol;
938-
}
939-
940933
FuncDecl *getPlusDecl() const {
941934
if (!cachedPlusFn) {
942935
cachedPlusFn = findOperatorDeclInProtocol(

0 commit comments

Comments
 (0)