Skip to content

Revert "SIL: let SingleValueInstruction only inherit from a single SILNode." #35600

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
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
45 changes: 20 additions & 25 deletions include/swift/SIL/ApplySite.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,28 @@ class ApplySite {

SILModule &getModule() const { return Inst->getModule(); }

static ApplySite isa(SILInstruction *inst) {
auto kind = ApplySiteKind::fromNodeKind(inst->getKind());
static ApplySite isa(SILNode *node) {
auto *i = dyn_cast<SILInstruction>(node);
if (!i)
return ApplySite();

auto kind = ApplySiteKind::fromNodeKind(i->getKind());
if (!kind)
return ApplySite();

switch (kind.getValue()) {
case ApplySiteKind::ApplyInst:
return ApplySite(cast<ApplyInst>(inst));
return ApplySite(cast<ApplyInst>(node));
case ApplySiteKind::BeginApplyInst:
return ApplySite(cast<BeginApplyInst>(inst));
return ApplySite(cast<BeginApplyInst>(node));
case ApplySiteKind::TryApplyInst:
return ApplySite(cast<TryApplyInst>(inst));
return ApplySite(cast<TryApplyInst>(node));
case ApplySiteKind::PartialApplyInst:
return ApplySite(cast<PartialApplyInst>(inst));
return ApplySite(cast<PartialApplyInst>(node));
}
llvm_unreachable("covered switch");
}

static ApplySite isa(SILValue value) {
if (auto *inst = value->getDefiningInstruction())
return ApplySite::isa(inst);
return ApplySite();
}

ApplySiteKind getKind() const { return ApplySiteKind(Inst->getKind()); }

explicit operator bool() const { return Inst != nullptr; }
Expand Down Expand Up @@ -183,8 +181,8 @@ class ApplySite {
/// Calls to (previous_)dynamic_function_ref have a dynamic target function so
/// we should not optimize them.
bool canOptimize() const {
return !swift::isa<DynamicFunctionRefInst>(getCallee()) &&
!swift::isa<PreviousDynamicFunctionRefInst>(getCallee());
return !DynamicFunctionRefInst::classof(getCallee()) &&
!PreviousDynamicFunctionRefInst::classof(getCallee());
}

/// Return the type.
Expand Down Expand Up @@ -495,27 +493,24 @@ class FullApplySite : public ApplySite {
FullApplySite(BeginApplyInst *inst) : ApplySite(inst) {}
FullApplySite(TryApplyInst *inst) : ApplySite(inst) {}

static FullApplySite isa(SILInstruction *inst) {
auto kind = FullApplySiteKind::fromNodeKind(inst->getKind());
static FullApplySite isa(SILNode *node) {
auto *i = dyn_cast<SILInstruction>(node);
if (!i)
return FullApplySite();
auto kind = FullApplySiteKind::fromNodeKind(i->getKind());
if (!kind)
return FullApplySite();
switch (kind.getValue()) {
case FullApplySiteKind::ApplyInst:
return FullApplySite(cast<ApplyInst>(inst));
return FullApplySite(cast<ApplyInst>(node));
case FullApplySiteKind::BeginApplyInst:
return FullApplySite(cast<BeginApplyInst>(inst));
return FullApplySite(cast<BeginApplyInst>(node));
case FullApplySiteKind::TryApplyInst:
return FullApplySite(cast<TryApplyInst>(inst));
return FullApplySite(cast<TryApplyInst>(node));
}
llvm_unreachable("covered switch");
}

static FullApplySite isa(SILValue value) {
if (auto *inst = value->getDefiningInstruction())
return FullApplySite::isa(inst);
return FullApplySite();
}

FullApplySiteKind getKind() const {
return FullApplySiteKind(getInstruction()->getKind());
}
Expand Down
9 changes: 6 additions & 3 deletions include/swift/SIL/DynamicCasts.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,17 @@ struct SILDynamicCastInst {
SILDynamicCastInst(ID *i) : inst(i) {}
#include "swift/SIL/SILNodes.def"

static SILDynamicCastInst getAs(SILInstruction *inst) {
auto kind = SILDynamicCastKind::fromNodeKind(inst->getKind());
static SILDynamicCastInst getAs(SILNode *node) {
auto *i = dyn_cast<SILInstruction>(node);
if (!i)
return SILDynamicCastInst();
auto kind = SILDynamicCastKind::fromNodeKind(i->getKind());
if (!kind)
return SILDynamicCastInst();
switch (kind.getValue()) {
#define DYNAMICCAST_INST(ID, PARENT) \
case SILDynamicCastKind::ID: \
return SILDynamicCastInst(cast<ID>(inst));
return SILDynamicCastInst(cast<ID>(node));
#include "swift/SIL/SILNodes.def"
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/PrettyStackTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#define SWIFT_SIL_PRETTYSTACKTRACE_H

#include "swift/SIL/SILLocation.h"
#include "swift/SIL/SILNode.h"
#include "llvm/Support/PrettyStackTrace.h"

namespace swift {
class ASTContext;
class SILFunction;
class SILNode;

void printSILLocationDescription(llvm::raw_ostream &out, SILLocation loc,
ASTContext &ctx);
Expand Down Expand Up @@ -74,7 +74,7 @@ class PrettyStackTraceSILNode : public llvm::PrettyStackTraceEntry {
const char *Action;

public:
PrettyStackTraceSILNode(const char *action, SILNodePointer node)
PrettyStackTraceSILNode(const char *action, const SILNode *node)
: Node(node), Action(action) {}

virtual void print(llvm::raw_ostream &OS) const override;
Expand Down
8 changes: 4 additions & 4 deletions include/swift/SIL/SILArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class SILArgument : public ValueBase {
explicit SILArgument(ValueKind subClassKind, SILType type,
ValueOwnershipKind ownershipKind,
const ValueDecl *inputDecl = nullptr)
: ValueBase(subClassKind, type),
: ValueBase(subClassKind, type, IsRepresentative::Yes),
parentBlock(nullptr), decl(inputDecl) {
Bits.SILArgument.VOKind = static_cast<unsigned>(ownershipKind);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ class SILArgument : public ValueBase {

static bool classof(const SILInstruction *) = delete;
static bool classof(const SILUndef *) = delete;
static bool classof(SILNodePointer node) {
static bool classof(const SILNode *node) {
return node->getKind() >= SILNodeKind::First_SILArgument &&
node->getKind() <= SILNodeKind::Last_SILArgument;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ class SILPhiArgument : public SILArgument {

static bool classof(const SILInstruction *) = delete;
static bool classof(const SILUndef *) = delete;
static bool classof(SILNodePointer node) {
static bool classof(const SILNode *node) {
return node->getKind() == SILNodeKind::SILPhiArgument;
}
};
Expand Down Expand Up @@ -322,7 +322,7 @@ class SILFunctionArgument : public SILArgument {

static bool classof(const SILInstruction *) = delete;
static bool classof(const SILUndef *) = delete;
static bool classof(SILNodePointer node) {
static bool classof(const SILNode *node) {
return node->getKind() == SILNodeKind::SILFunctionArgument;
}
};
Expand Down
Loading