Skip to content

[sil] Change usages of SILArguments in SILArgument.h to use exhaustiv… #28526

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
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
57 changes: 40 additions & 17 deletions include/swift/SIL/SILArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,50 +334,73 @@ class SILFunctionArgument : public SILArgument {
//===----------------------------------------------------------------------===//

inline bool SILArgument::isPhiArgument() const {
if (auto *phiArg = dyn_cast<SILPhiArgument>(this))
return phiArg->isPhiArgument();

return false;
switch (getKind()) {
case SILArgumentKind::SILPhiArgument:
return cast<SILPhiArgument>(this)->isPhiArgument();
case SILArgumentKind::SILFunctionArgument:
return false;
}
llvm_unreachable("Covered switch is not covered?!");
}

inline SILValue
SILArgument::getIncomingPhiValue(SILBasicBlock *predBlock) const {
if (isa<SILFunctionArgument>(this))
switch (getKind()) {
case SILArgumentKind::SILPhiArgument:
return cast<SILPhiArgument>(this)->getIncomingPhiValue(predBlock);
case SILArgumentKind::SILFunctionArgument:
return SILValue();
return cast<SILPhiArgument>(this)->getIncomingPhiValue(predBlock);
}
llvm_unreachable("Covered switch is not covered?!");
}

inline bool SILArgument::getIncomingPhiValues(
SmallVectorImpl<SILValue> &returnedPhiValues) const {
if (isa<SILFunctionArgument>(this))
switch (getKind()) {
case SILArgumentKind::SILPhiArgument:
return cast<SILPhiArgument>(this)->getIncomingPhiValues(returnedPhiValues);
case SILArgumentKind::SILFunctionArgument:
return false;
return cast<SILPhiArgument>(this)->getIncomingPhiValues(returnedPhiValues);
}
llvm_unreachable("Covered switch is not covered?!");
}

inline bool SILArgument::getIncomingPhiValues(
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
&returnedPredAndPhiValuePairs) const {
if (isa<SILFunctionArgument>(this))
switch (getKind()) {
case SILArgumentKind::SILPhiArgument:
return cast<SILPhiArgument>(this)->getIncomingPhiValues(
returnedPredAndPhiValuePairs);
case SILArgumentKind::SILFunctionArgument:
return false;
return cast<SILPhiArgument>(this)->getIncomingPhiValues(
returnedPredAndPhiValuePairs);
}
llvm_unreachable("Covered switch is not covered?!");
}

inline bool SILArgument::getSingleTerminatorOperands(
SmallVectorImpl<SILValue> &returnedSingleTermOperands) const {
if (isa<SILFunctionArgument>(this))
switch (getKind()) {
case SILArgumentKind::SILPhiArgument:
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
returnedSingleTermOperands);
case SILArgumentKind::SILFunctionArgument:
return false;
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
returnedSingleTermOperands);
}
llvm_unreachable("Covered switch is not covered?!");
}

inline bool SILArgument::getSingleTerminatorOperands(
SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>>
&returnedSingleTermOperands) const {
if (isa<SILFunctionArgument>(this))
switch (getKind()) {
case SILArgumentKind::SILPhiArgument:
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
returnedSingleTermOperands);
case SILArgumentKind::SILFunctionArgument:
return false;
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(
returnedSingleTermOperands);
}
llvm_unreachable("Covered switch is not covered?!");
}

} // end swift namespace
Expand Down