forked from apple/swift
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SILBuilder: add an API to insert _after_ an instruction.
... and use that API in FullApplySite::insertAfterInvocation. Also change FullApplySite::insertAfterInvocation/insertAfterFullEvaluation to directly pass a SILBuilder instead of just an insertion point to the callback. This makes more sense (given the function names) and simplifies the usages. It's a NFC.
- Loading branch information
Showing
8 changed files
with
101 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===--- ApplySite.cpp - Wrapper around apply instructions ----------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "swift/SIL/ApplySite.h" | ||
#include "swift/SIL/SILBuilder.h" | ||
|
||
|
||
using namespace swift; | ||
|
||
void FullApplySite::insertAfterInvocation(function_ref<void(SILBuilder &)> func) const { | ||
SILBuilderWithScope::insertAfter(getInstruction(), func); | ||
} | ||
|
||
void FullApplySite::insertAfterFullEvaluation( | ||
function_ref<void(SILBuilder &)> func) const { | ||
switch (getKind()) { | ||
case FullApplySiteKind::ApplyInst: | ||
case FullApplySiteKind::TryApplyInst: | ||
return insertAfterInvocation(func); | ||
case FullApplySiteKind::BeginApplyInst: | ||
SmallVector<EndApplyInst *, 2> endApplies; | ||
SmallVector<AbortApplyInst *, 2> abortApplies; | ||
auto *bai = cast<BeginApplyInst>(getInstruction()); | ||
bai->getCoroutineEndPoints(endApplies, abortApplies); | ||
for (auto *eai : endApplies) { | ||
SILBuilderWithScope builder(std::next(eai->getIterator())); | ||
func(builder); | ||
} | ||
for (auto *aai : abortApplies) { | ||
SILBuilderWithScope builder(std::next(aai->getIterator())); | ||
func(builder); | ||
} | ||
return; | ||
} | ||
llvm_unreachable("covered switch isn't covered"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
target_sources(swiftSIL PRIVATE | ||
AbstractionPattern.cpp | ||
ApplySite.cpp | ||
Bridging.cpp | ||
Linker.cpp | ||
Notifications.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters