Skip to content

Commit bc86fe5

Browse files
committed
Hoist ArrayCallKind to a separate file
1 parent 66dc1cc commit bc86fe5

File tree

4 files changed

+48
-31
lines changed

4 files changed

+48
-31
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//===--- ArrayCallKind.h -------------------------------------- -*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef ARRAY_CALL_KIND_H
14+
#define ARRAY_CALL_KIND_H
15+
16+
/// The kind of array operation identified by looking at the semantics attribute
17+
/// of the called function.
18+
enum class ArrayCallKind {
19+
kNone = 0,
20+
kArrayPropsIsNativeTypeChecked,
21+
kCheckSubscript,
22+
kCheckIndex,
23+
kGetCount,
24+
kGetCapacity,
25+
kGetElement,
26+
kGetElementAddress,
27+
kMakeMutable,
28+
kEndMutation,
29+
kMutateUnknown,
30+
kReserveCapacityForAppend,
31+
kWithUnsafeMutableBufferPointer,
32+
kAppendContentsOf,
33+
kAppendElement,
34+
// The following two semantic function kinds return the result @owned
35+
// instead of operating on self passed as parameter. If you are adding
36+
// a function, and it has a self parameter, make sure that it is defined
37+
// before this comment.
38+
kArrayInit,
39+
kArrayInitEmpty,
40+
kArrayUninitialized,
41+
kArrayUninitializedIntrinsic,
42+
kArrayFinalizeIntrinsic
43+
};
44+
45+
#endif

include/swift/SILOptimizer/Analysis/ArraySemantic.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,12 @@
1414
#define SWIFT_SILOPTIMIZER_ANALYSIS_ARRAYSEMANTIC_H
1515

1616
#include "swift/SIL/SILInstruction.h"
17+
#include "swift/SILOptimizer/Analysis/ArrayCallKind.h"
1718

1819
namespace swift {
1920

2021
class DominanceInfo;
2122

22-
/// The kind of array operation identified by looking at the semantics attribute
23-
/// of the called function.
24-
enum class ArrayCallKind {
25-
kNone = 0,
26-
kArrayPropsIsNativeTypeChecked,
27-
kCheckSubscript,
28-
kCheckIndex,
29-
kGetCount,
30-
kGetCapacity,
31-
kGetElement,
32-
kGetElementAddress,
33-
kMakeMutable,
34-
kEndMutation,
35-
kMutateUnknown,
36-
kReserveCapacityForAppend,
37-
kWithUnsafeMutableBufferPointer,
38-
kAppendContentsOf,
39-
kAppendElement,
40-
// The following two semantic function kinds return the result @owned
41-
// instead of operating on self passed as parameter. If you are adding
42-
// a function, and it has a self parameter, make sure that it is defined
43-
// before this comment.
44-
kArrayInit,
45-
kArrayInitEmpty,
46-
kArrayUninitialized,
47-
kArrayUninitializedIntrinsic,
48-
kArrayFinalizeIntrinsic
49-
};
50-
5123
/// Return true is the given function is an array semantics call.
5224
ArrayCallKind getArraySemanticsKind(SILFunction *f);
5325

lib/SILOptimizer/LoopTransforms/ForEachLoopUnroll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void ArrayInfo::classifyUsesOfArray(SILValue arrayValue) {
337337
if (arrayOp.doesNotChangeArray())
338338
continue;
339339

340-
if (arrayOp.getKind() == swift::ArrayCallKind::kArrayFinalizeIntrinsic) {
340+
if (arrayOp.getKind() == ArrayCallKind::kArrayFinalizeIntrinsic) {
341341
classifyUsesOfArray((ApplyInst *)arrayOp);
342342
continue;
343343
}

lib/SILOptimizer/Transforms/DeadObjectElimination.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ recursivelyCollectInteriorUses(ValueBase *DefInst,
686686
continue;
687687
}
688688
ArraySemanticsCall AS(svi);
689-
if (AS.getKind() == swift::ArrayCallKind::kArrayFinalizeIntrinsic) {
689+
if (AS.getKind() == ArrayCallKind::kArrayFinalizeIntrinsic) {
690690
if (!recursivelyCollectInteriorUses(svi, AddressNode, IsInteriorAddress))
691691
return false;
692692
continue;

0 commit comments

Comments
 (0)