Skip to content

[gardening] Rename references to SILPHIArgument => SILPhiArgument. #19557

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
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions include/swift/SIL/MemAccessUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ObjectProjection {
/// while global variables and class properties are not. Unidentified storage is
/// associated with a SILValue that produces the accessed address but has not
/// been determined to be the base of a storage object. It may, for example,
/// be a SILPHIArgument.
/// be a SILPhiArgument.
///
/// An invalid AccessedStorage object is marked Unidentified and contains an
/// invalid value. This signals that analysis has failed to recognize an
Expand Down Expand Up @@ -380,7 +380,7 @@ namespace swift {
/// The returned AccessedStorage represents the best attempt to find the base of
/// the storage object being accessed at `sourceAddr`. This may be a fully
/// identified storage base of known kind, or a valid but Unidentified storage
/// object, such as a SILPHIArgument.
/// object, such as a SILPhiArgument.
///
/// This may return an invalid storage object if the address producer is not
/// recognized by a whitelist of recognizable access patterns. The result must
Expand Down
34 changes: 17 additions & 17 deletions include/swift/SIL/SILArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SILArgument : public ValueBase {
friend SILBasicBlock;
};

class SILPHIArgument : public SILArgument {
class SILPhiArgument : public SILArgument {
public:
/// Return true if this is block argument is actually a phi argument as
/// opposed to a cast or projection.
Expand All @@ -155,22 +155,22 @@ class SILPHIArgument : public SILArgument {
/// If this argument is a phi, return the incoming phi value for the given
/// predecessor BB. If this argument is not a phi, return an invalid SILValue.
///
/// FIXME: Once SILPHIArgument actually implies that it is a phi argument,
/// FIXME: Once SILPhiArgument actually implies that it is a phi argument,
/// this will be guaranteed to return a valid SILValue.
SILValue getIncomingPhiValue(SILBasicBlock *BB);

/// If this argument is a phi, populate `OutArray` with the incoming phi
/// values for each predecessor BB. If this argument is not a phi, return
/// false.
///
/// FIXME: Once SILPHIArgument actually implies that it is a phi argument,
/// FIXME: Once SILPhiArgument actually implies that it is a phi argument,
/// this will always succeed.
bool getIncomingPhiValues(llvm::SmallVectorImpl<SILValue> &OutArray);

/// If this argument is a phi, populate `OutArray` with each predecessor block
/// and its incoming phi value. If this argument is not a phi, return false.
///
/// FIXME: Once SILPHIArgument actually implies that it is a phi argument,
/// FIXME: Once SILPhiArgument actually implies that it is a phi argument,
/// this will always succeed.
bool getIncomingPhiValues(
llvm::SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>> &OutArray);
Expand Down Expand Up @@ -205,24 +205,24 @@ class SILPHIArgument : public SILArgument {
static bool classof(const SILInstruction *) = delete;
static bool classof(const SILUndef *) = delete;
static bool classof(const SILNode *node) {
return node->getKind() == SILNodeKind::SILPHIArgument;
return node->getKind() == SILNodeKind::SILPhiArgument;
}

private:
friend SILBasicBlock;
SILPHIArgument(SILBasicBlock *ParentBB, SILType Ty, ValueOwnershipKind OwnershipKind,
SILPhiArgument(SILBasicBlock *ParentBB, SILType Ty, ValueOwnershipKind OwnershipKind,
const ValueDecl *D = nullptr)
: SILArgument(ValueKind::SILPHIArgument, ParentBB, Ty, OwnershipKind, D) {}
SILPHIArgument(SILBasicBlock *ParentBB, SILBasicBlock::arg_iterator Pos,
: SILArgument(ValueKind::SILPhiArgument, ParentBB, Ty, OwnershipKind, D) {}
SILPhiArgument(SILBasicBlock *ParentBB, SILBasicBlock::arg_iterator Pos,
SILType Ty, ValueOwnershipKind OwnershipKind,
const ValueDecl *D = nullptr)
: SILArgument(ValueKind::SILPHIArgument, ParentBB, Pos, Ty, OwnershipKind, D) {}
: SILArgument(ValueKind::SILPhiArgument, ParentBB, Pos, Ty, OwnershipKind, D) {}

// A special constructor, only intended for use in
// SILBasicBlock::replacePHIArg.
explicit SILPHIArgument(SILType Ty, ValueOwnershipKind OwnershipKind,
explicit SILPhiArgument(SILType Ty, ValueOwnershipKind OwnershipKind,
const ValueDecl *D = nullptr)
: SILArgument(ValueKind::SILPHIArgument, Ty, OwnershipKind, D) {}
: SILArgument(ValueKind::SILPhiArgument, Ty, OwnershipKind, D) {}
};

class SILFunctionArgument : public SILArgument {
Expand Down Expand Up @@ -283,7 +283,7 @@ class SILFunctionArgument : public SILArgument {
//===----------------------------------------------------------------------===//

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

return false;
Expand All @@ -292,35 +292,35 @@ inline bool SILArgument::isPhiArgument() {
inline SILValue SILArgument::getIncomingPhiValue(SILBasicBlock *BB) {
if (isa<SILFunctionArgument>(this))
return SILValue();
return cast<SILPHIArgument>(this)->getIncomingPhiValue(BB);
return cast<SILPhiArgument>(this)->getIncomingPhiValue(BB);
}

inline bool
SILArgument::getIncomingPhiValues(llvm::SmallVectorImpl<SILValue> &OutArray) {
if (isa<SILFunctionArgument>(this))
return false;
return cast<SILPHIArgument>(this)->getIncomingPhiValues(OutArray);
return cast<SILPhiArgument>(this)->getIncomingPhiValues(OutArray);
}

inline bool SILArgument::getIncomingPhiValues(
llvm::SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>> &OutArray) {
if (isa<SILFunctionArgument>(this))
return false;
return cast<SILPHIArgument>(this)->getIncomingPhiValues(OutArray);
return cast<SILPhiArgument>(this)->getIncomingPhiValues(OutArray);
}

inline bool SILArgument::getSingleTerminatorOperands(
llvm::SmallVectorImpl<SILValue> &OutArray) {
if (isa<SILFunctionArgument>(this))
return false;
return cast<SILPHIArgument>(this)->getSingleTerminatorOperands(OutArray);
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(OutArray);
}

inline bool SILArgument::getSingleTerminatorOperands(
llvm::SmallVectorImpl<std::pair<SILBasicBlock *, SILValue>> &OutArray) {
if (isa<SILFunctionArgument>(this))
return false;
return cast<SILPHIArgument>(this)->getSingleTerminatorOperands(OutArray);
return cast<SILPhiArgument>(this)->getSingleTerminatorOperands(OutArray);
}

} // end swift namespace
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SIL/SILArgumentArrayRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
namespace swift {

class SILArgument;
class SILPHIArgument;
class SILPhiArgument;
class SILFunctionArgument;

using PHIArgumentArrayRef =
TransformArrayRef<function_ref<SILPHIArgument *(SILArgument *)>>;
using PhiArgumentArrayRef =
TransformArrayRef<function_ref<SILPhiArgument *(SILArgument *)>>;

using FunctionArgumentArrayRef =
TransformArrayRef<function_ref<SILFunctionArgument *(SILArgument *)>>;
Expand Down
22 changes: 11 additions & 11 deletions include/swift/SIL/SILBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace swift {

class SILFunction;
class SILArgument;
class SILPHIArgument;
class SILPhiArgument;
class SILFunctionArgument;
class SILPrintContext;

Expand Down Expand Up @@ -165,7 +165,7 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
/// Iterator over the PHI arguments of a basic block.
/// Defines an implicit cast operator on the iterator, so that this iterator
/// can be used in the SSAUpdaterImpl.
template <typename PHIArgT = SILPHIArgument,
template <typename PHIArgT = SILPhiArgument,
typename IteratorT = arg_iterator>
class phi_iterator_impl {
private:
Expand All @@ -180,7 +180,7 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
bool operator!=(const phi_iterator_impl& x) const { return !operator==(x); }
};
typedef phi_iterator_impl<> phi_iterator;
typedef phi_iterator_impl<const SILPHIArgument,
typedef phi_iterator_impl<const SILPhiArgument,
SILBasicBlock::const_arg_iterator>
const_phi_iterator;

Expand All @@ -194,9 +194,9 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {

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

/// Returns a transform array ref that performs llvm::cast<SILPHIArgument> on
/// Returns a transform array ref that performs llvm::cast<SILPhiArgument> on
/// each argument and then returns the downcasted value.
PHIArgumentArrayRef getPHIArguments() const;
PhiArgumentArrayRef getPhiArguments() const;

/// Returns a transform array ref that performs
/// llvm::cast<SILFunctionArgument> on each argument and then returns the
Expand Down Expand Up @@ -234,27 +234,27 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
/// Replace the \p{i}th BB arg with a new BBArg with SILType \p Ty and
/// ValueDecl
/// \p D.
SILPHIArgument *replacePHIArgument(unsigned i, SILType Ty,
SILPhiArgument *replacePhiArgument(unsigned i, SILType Ty,
ValueOwnershipKind Kind,
const ValueDecl *D = nullptr);

/// Allocate a new argument of type \p Ty and append it to the argument
/// list. Optionally you can pass in a value decl parameter.
SILPHIArgument *createPHIArgument(SILType Ty, ValueOwnershipKind Kind,
SILPhiArgument *createPhiArgument(SILType Ty, ValueOwnershipKind Kind,
const ValueDecl *D = nullptr);

/// Insert a new SILPHIArgument with type \p Ty and \p Decl at position \p
/// Insert a new SILPhiArgument with type \p Ty and \p Decl at position \p
/// Pos.
SILPHIArgument *insertPHIArgument(arg_iterator Pos, SILType Ty,
SILPhiArgument *insertPhiArgument(arg_iterator Pos, SILType Ty,
ValueOwnershipKind Kind,
const ValueDecl *D = nullptr);

SILPHIArgument *insertPHIArgument(unsigned Index, SILType Ty,
SILPhiArgument *insertPhiArgument(unsigned Index, SILType Ty,
ValueOwnershipKind Kind,
const ValueDecl *D = nullptr) {
arg_iterator Pos = ArgumentList.begin();
std::advance(Pos, Index);
return insertPHIArgument(Pos, Ty, Kind, D);
return insertPhiArgument(Pos, Ty, Kind, D);
}

/// \brief Remove all block arguments.
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ SILCloner<ImplClass>::visitSILBasicBlock(SILBasicBlock* BB) {
auto *MappedBB = F.createBasicBlock();
BBMap.insert(std::make_pair(Succ.getBB(), MappedBB));
// Create new arguments for each of the original block's arguments.
for (auto *Arg : Succ.getBB()->getPHIArguments()) {
SILValue MappedArg = MappedBB->createPHIArgument(
for (auto *Arg : Succ.getBB()->getPhiArguments()) {
SILValue MappedArg = MappedBB->createPhiArgument(
getOpType(Arg->getType()), Arg->getOwnershipKind());

ValueMap.insert(std::make_pair(Arg, MappedArg));
Expand Down
12 changes: 6 additions & 6 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SILInstructionResultArray;
class SILOpenedArchetypesState;
class SILType;
class SILArgument;
class SILPHIArgument;
class SILPhiArgument;
class SILUndef;
class Stmt;
class StringLiteralExpr;
Expand Down Expand Up @@ -6608,7 +6608,7 @@ class TermInst : public NonValueInstruction {

using SuccessorBlockArgumentsListTy =
TransformRange<ConstSuccessorListTy,
function_ref<PHIArgumentArrayRef(const SILSuccessor &)>>;
function_ref<PhiArgumentArrayRef(const SILSuccessor &)>>;

/// Return the range of Argument arrays for each successor of this
/// block.
Expand Down Expand Up @@ -6827,10 +6827,10 @@ class BranchInst final
unsigned getNumArgs() const { return getAllOperands().size(); }
SILValue getArg(unsigned i) const { return getAllOperands()[i].get(); }

/// Return the SILPHIArgument for the given operand.
/// Return the SILPhiArgument for the given operand.
///
/// See SILArgument.cpp.
const SILPHIArgument *getArgForOperand(const Operand *oper) const;
const SILPhiArgument *getArgForOperand(const Operand *oper) const;
};

/// A conditional branch.
Expand Down Expand Up @@ -6972,14 +6972,14 @@ class CondBranchInst final
SILValue getArgForDestBB(const SILBasicBlock *DestBB,
unsigned ArgIndex) const;

/// Return the SILPHIArgument from either the true or false destination for
/// Return the SILPhiArgument from either the true or false destination for
/// the given operand.
///
/// Returns nullptr for an operand with no block argument
/// (i.e the branch condition).
///
/// See SILArgument.cpp.
const SILPHIArgument *getArgForOperand(const Operand *oper) const;
const SILPhiArgument *getArgForOperand(const Operand *oper) const;

void swapSuccessors();
};
Expand Down
8 changes: 4 additions & 4 deletions include/swift/SIL/SILNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@
ABSTRACT_NODE(ValueBase, SILNode)

ABSTRACT_VALUE(SILArgument, ValueBase)
ARGUMENT(SILPHIArgument, SILArgument)
ARGUMENT(SILPhiArgument, SILArgument)
ARGUMENT(SILFunctionArgument, SILArgument)
VALUE_RANGE(SILArgument, SILPHIArgument, SILFunctionArgument)
VALUE_RANGE(SILArgument, SILPhiArgument, SILFunctionArgument)

ABSTRACT_VALUE(MultipleValueInstructionResult, ValueBase)
MULTIPLE_VALUE_INST_RESULT(BeginApplyResult, MultipleValueInstructionResult)
Expand Down Expand Up @@ -614,7 +614,7 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction)

SINGLE_VALUE_INST_RANGE(SingleValueInstruction, AllocStackInst, KeyPathInst)

NODE_RANGE(ValueBase, SILPHIArgument, KeyPathInst)
NODE_RANGE(ValueBase, SILPhiArgument, KeyPathInst)

// Terminators
ABSTRACT_INST(TermInst, SILInstruction)
Expand Down Expand Up @@ -776,7 +776,7 @@ MULTIPLE_VALUE_INST(DestructureTupleInst, destructure_tuple,
INST_RANGE(MultipleValueInstruction, BeginApplyInst, DestructureTupleInst)

NODE_RANGE(SILInstruction, AllocStackInst, DestructureTupleInst)
NODE_RANGE(SILNode, SILPHIArgument, DestructureTupleInst)
NODE_RANGE(SILNode, SILPhiArgument, DestructureTupleInst)

#undef SINGLE_VALUE_INST_RANGE
#undef INST_RANGE
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SILOptimizer/Utils/Local.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ class EdgeThreadingCloner : public BaseThreadingCloner {

// Create block arguments.
for (unsigned ArgIdx : range(EdgeBB->getNumArguments())) {
auto *DestPHIArg = cast<SILPHIArgument>(EdgeBB->getArgument(ArgIdx));
auto *DestPHIArg = cast<SILPhiArgument>(EdgeBB->getArgument(ArgIdx));
assert(BI->getArg(ArgIdx)->getType() == DestPHIArg->getType() &&
"Types must match");
auto *BlockArg = DestBB->createPHIArgument(
auto *BlockArg = DestBB->createPhiArgument(
DestPHIArg->getType(), DestPHIArg->getOwnershipKind());
ValueMap[DestPHIArg] = SILValue(BlockArg);
AvailVals.push_back(std::make_pair(DestPHIArg, BlockArg));
Expand Down
8 changes: 4 additions & 4 deletions include/swift/SILOptimizer/Utils/SILSSAUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ namespace llvm {

namespace swift {

class SILPHIArgument;
class SILPhiArgument;
class SILBasicBlock;
class SILType;
class SILUndef;

/// Independent utility that canonicalizes BB arguments by reusing structurally
/// equivalent arguments and replacing the original arguments with casts.
SILValue replaceBBArgWithCast(SILPHIArgument *Arg);
SILValue replaceBBArgWithCast(SILPhiArgument *Arg);

/// This class updates SSA for a set of SIL instructions defined in multiple
/// blocks.
Expand All @@ -49,15 +49,15 @@ class SILSSAUpdater {
std::unique_ptr<SILUndef, void(*)(SILUndef *)> PHISentinel;

// If not null updated with inserted 'phi' nodes (SILArgument).
SmallVectorImpl<SILPHIArgument *> *InsertedPHIs;
SmallVectorImpl<SILPhiArgument *> *InsertedPHIs;

// Not copyable.
void operator=(const SILSSAUpdater &) = delete;
SILSSAUpdater(const SILSSAUpdater &) = delete;

public:
explicit SILSSAUpdater(
SmallVectorImpl<SILPHIArgument *> *InsertedPHIs = nullptr);
SmallVectorImpl<SILPhiArgument *> *InsertedPHIs = nullptr);
~SILSSAUpdater();

/// \brief Initialize for a use of a value of type.
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/LoadableByAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ static void convertBBArgType(SILBuilder &argBuilder, SILType newSILType,
SILUndef::get(newSILType, arg->getFunction()->getModule()));

arg->replaceAllUsesWith(copyArg);
arg = arg->getParent()->replacePHIArgument(arg->getIndex(), newSILType,
arg = arg->getParent()->replacePhiArgument(arg->getIndex(), newSILType,
arg->getOwnershipKind());

copyArg->replaceAllUsesWith(arg);
Expand Down
4 changes: 2 additions & 2 deletions lib/ParseSIL/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5094,7 +5094,7 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
return true;

BB = getBBForDefinition(BBName, NameLoc);
// For now, since we always assume that PHIArguments have
// For now, since we always assume that PhiArguments have
// ValueOwnershipKind::Any, do not parse or do anything special. Eventually
// we will parse the convention.
bool IsEntry = BB->isEntry();
Expand Down Expand Up @@ -5126,7 +5126,7 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
if (IsEntry) {
Arg = BB->createFunctionArgument(Ty);
} else {
Arg = BB->createPHIArgument(Ty, OwnershipKind);
Arg = BB->createPhiArgument(Ty, OwnershipKind);
}
setLocalValue(Arg, Name, NameLoc);
} while (P.consumeIf(tok::comma));
Expand Down
Loading