Skip to content

Commit b544355

Browse files
authored
Merge pull request swiftlang#28525 from gottesmm/pr-026a0d4e88ada556787a0f4b3c2c9844ec67e6e1
2 parents bf6527b + df47eb2 commit b544355

17 files changed

+35
-50
lines changed

include/swift/SIL/SILArgumentArrayRef.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
namespace swift {
2727

2828
class SILArgument;
29-
class SILPhiArgument;
30-
class SILFunctionArgument;
3129

32-
using PhiArgumentArrayRef =
33-
TransformRange<ArrayRef<SILArgument *>, SILPhiArgument *(*)(SILArgument *)>;
34-
35-
using FunctionArgumentArrayRef =
36-
TransformRange<ArrayRef<SILArgument *>,
37-
SILFunctionArgument *(*)(SILArgument *)>;
30+
#define ARGUMENT(NAME, PARENT) \
31+
class NAME; \
32+
using NAME##ArrayRef = \
33+
TransformRange<ArrayRef<SILArgument *>, NAME *(*)(SILArgument *)>;
34+
#include "swift/SIL/SILNodes.def"
3835

3936
} // namespace swift
4037

include/swift/SIL/SILBasicBlock.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace swift {
2626

2727
class SILFunction;
2828
class SILArgument;
29-
class SILPhiArgument;
30-
class SILFunctionArgument;
3129
class SILPrintContext;
3230

3331
class SILBasicBlock :
@@ -193,14 +191,10 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
193191

194192
ArrayRef<SILArgument *> getArguments() const { return ArgumentList; }
195193

196-
/// Returns a transform array ref that performs llvm::cast<SILPhiArgument> on
194+
/// Returns a transform array ref that performs llvm::cast<NAME>
197195
/// each argument and then returns the downcasted value.
198-
PhiArgumentArrayRef getPhiArguments() const;
199-
200-
/// Returns a transform array ref that performs
201-
/// llvm::cast<SILFunctionArgument> on each argument and then returns the
202-
/// downcasted value.
203-
FunctionArgumentArrayRef getFunctionArguments() const;
196+
#define ARGUMENT(NAME, PARENT) NAME##ArrayRef get##NAME##s() const;
197+
#include "swift/SIL/SILNodes.def"
204198

205199
unsigned getNumArguments() const { return ArgumentList.size(); }
206200
const SILArgument *getArgument(unsigned i) const { return ArgumentList[i]; }

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ void SILCloner<ImplClass>::clonePhiArgs(SILBasicBlock *oldBB) {
646646
auto *mappedBB = BBMap[oldBB];
647647

648648
// Create new arguments for each of the original block's arguments.
649-
for (auto *Arg : oldBB->getPhiArguments()) {
649+
for (auto *Arg : oldBB->getSILPhiArguments()) {
650650
SILValue mappedArg = mappedBB->createPhiArgument(
651651
getOpType(Arg->getType()), Arg->getOwnershipKind());
652652

include/swift/SIL/SILInstruction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6989,8 +6989,8 @@ class TermInst : public NonValueInstruction {
69896989
}
69906990

69916991
using SuccessorBlockArgumentsListTy =
6992-
TransformRange<ConstSuccessorListTy,
6993-
function_ref<PhiArgumentArrayRef(const SILSuccessor &)>>;
6992+
TransformRange<ConstSuccessorListTy, function_ref<SILPhiArgumentArrayRef(
6993+
const SILSuccessor &)>>;
69946994

69956995
/// Return the range of Argument arrays for each successor of this
69966996
/// block.

lib/SIL/OperandOwnership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ OperandOwnershipKindClassifier::visitSwitchEnumInst(SwitchEnumInst *sei) {
455455
// and merge them.
456456
auto mergedKind = ValueOwnershipKind::merge(makeTransformRange(
457457
sei->getSuccessorBlockArguments(),
458-
[&](PhiArgumentArrayRef array) -> ValueOwnershipKind {
458+
[&](SILPhiArgumentArrayRef array) -> ValueOwnershipKind {
459459
// If the array is empty, we have a non-payloaded case. Return any.
460460
if (array.empty())
461461
return ValueOwnershipKind::None;

lib/SIL/SILBasicBlock.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ void SILBasicBlock::cloneArgumentList(SILBasicBlock *Other) {
129129
"Expected to both blocks to be entries or not");
130130
if (isEntry()) {
131131
assert(args_empty() && "Expected to have no arguments");
132-
for (auto *FuncArg : Other->getFunctionArguments()) {
132+
for (auto *FuncArg : Other->getSILFunctionArguments()) {
133133
createFunctionArgument(FuncArg->getType(),
134134
FuncArg->getDecl());
135135
}
136136
return;
137137
}
138138

139-
for (auto *PHIArg : Other->getPhiArguments()) {
139+
for (auto *PHIArg : Other->getSILPhiArguments()) {
140140
createPhiArgument(PHIArg->getType(), PHIArg->getOwnershipKind(),
141141
PHIArg->getDecl());
142142
}
@@ -359,18 +359,12 @@ bool SILBasicBlock::isEntry() const {
359359
}
360360

361361
/// Declared out of line so we can have a declaration of SILArgument.
362-
PhiArgumentArrayRef SILBasicBlock::getPhiArguments() const {
363-
return PhiArgumentArrayRef(getArguments(), [](SILArgument *arg) {
364-
return cast<SILPhiArgument>(arg);
365-
});
366-
}
367-
368-
/// Declared out of line so we can have a declaration of SILArgument.
369-
FunctionArgumentArrayRef SILBasicBlock::getFunctionArguments() const {
370-
return FunctionArgumentArrayRef(getArguments(), [](SILArgument *arg) {
371-
return cast<SILFunctionArgument>(arg);
372-
});
373-
}
362+
#define ARGUMENT(NAME, PARENT) \
363+
NAME##ArrayRef SILBasicBlock::get##NAME##s() const { \
364+
return NAME##ArrayRef(getArguments(), \
365+
[](SILArgument *arg) { return cast<NAME>(arg); }); \
366+
}
367+
#include "swift/SIL/SILNodes.def"
374368

375369
/// Returns true if this block ends in an unreachable or an apply of a
376370
/// no-return apply or builtin.

lib/SIL/SILInstructions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,9 +1223,9 @@ bool TermInst::isProgramTerminating() const {
12231223

12241224
TermInst::SuccessorBlockArgumentsListTy
12251225
TermInst::getSuccessorBlockArguments() const {
1226-
function_ref<PhiArgumentArrayRef(const SILSuccessor &)> op;
1227-
op = [](const SILSuccessor &succ) -> PhiArgumentArrayRef {
1228-
return succ.getBB()->getPhiArguments();
1226+
function_ref<SILPhiArgumentArrayRef(const SILSuccessor &)> op;
1227+
op = [](const SILSuccessor &succ) -> SILPhiArgumentArrayRef {
1228+
return succ.getBB()->getSILPhiArguments();
12291229
};
12301230
return SuccessorBlockArgumentsListTy(getSuccessors(), op);
12311231
}

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ bool SILValueOwnershipChecker::gatherUsers(
349349
//
350350
// TODO: We could ignore this error and emit a more specific error on the
351351
// actual terminator.
352-
for (auto *succArg : succBlock->getPhiArguments()) {
352+
for (auto *succArg : succBlock->getSILPhiArguments()) {
353353
// *NOTE* We do not emit an error here since we want to allow for more
354354
// specific errors to be found during use_verification.
355355
//

lib/SILOptimizer/Analysis/ARCAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ void ConsumedArgToEpilogueReleaseMatcher::collectMatchingDestroyAddresses(
843843
SILFunction::iterator anotherEpilogueBB =
844844
(Kind == ExitKind::Return) ? F->findThrowBB() : F->findReturnBB();
845845

846-
for (auto *arg : F->begin()->getFunctionArguments()) {
846+
for (auto *arg : F->begin()->getSILFunctionArguments()) {
847847
if (arg->isIndirectResult())
848848
continue;
849849
if (arg->getArgumentConvention() != SILArgumentConvention::Indirect_In)

lib/SILOptimizer/FunctionSignatureTransforms/ArgumentExplosionTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ bool FunctionSignatureTransform::ArgumentExplosionAnalyzeParameters() {
320320
SILFunction *F = TransformDescriptor.OriginalFunction;
321321
// Did we decide we should optimize any parameter?
322322
bool SignatureOptimize = false;
323-
auto Args = F->begin()->getFunctionArguments();
323+
auto Args = F->begin()->getSILFunctionArguments();
324324
ConsumedArgToEpilogueReleaseMatcher ArgToReturnReleaseMap(
325325
RCIA->get(F), F, {SILArgumentConvention::Direct_Owned});
326326

0 commit comments

Comments
 (0)