|
21 | 21 | #ifndef SWIFT_SIL_APPLYSITE_H
|
22 | 22 | #define SWIFT_SIL_APPLYSITE_H
|
23 | 23 |
|
| 24 | +#include "swift/Basic/STLExtras.h" |
24 | 25 | #include "swift/SIL/SILArgument.h"
|
25 | 26 | #include "swift/SIL/SILBasicBlock.h"
|
26 | 27 | #include "swift/SIL/SILFunction.h"
|
|
29 | 30 |
|
30 | 31 | namespace swift {
|
31 | 32 |
|
| 33 | +class FullApplySite; |
| 34 | + |
32 | 35 | //===----------------------------------------------------------------------===//
|
33 | 36 | // ApplySite
|
34 | 37 | //===----------------------------------------------------------------------===//
|
@@ -396,6 +399,10 @@ class ApplySite {
|
396 | 399 | llvm_unreachable("covered switch");
|
397 | 400 | }
|
398 | 401 |
|
| 402 | + /// Returns true if \p op is an operand that passes an indirect |
| 403 | + /// result argument to the apply site. |
| 404 | + bool isIndirectResultOperand(const Operand &op) const; |
| 405 | + |
399 | 406 | /// Return whether the given apply is of a formally-throwing function
|
400 | 407 | /// which is statically known not to throw.
|
401 | 408 | bool isNonThrowing() const {
|
@@ -425,6 +432,10 @@ class ApplySite {
|
425 | 432 | }
|
426 | 433 |
|
427 | 434 | void dump() const LLVM_ATTRIBUTE_USED { getInstruction()->dump(); }
|
| 435 | + |
| 436 | + /// Attempt to cast this apply site to a full apply site, returning None on |
| 437 | + /// failure. |
| 438 | + Optional<FullApplySite> asFullApplySite() const; |
428 | 439 | };
|
429 | 440 |
|
430 | 441 | //===----------------------------------------------------------------------===//
|
@@ -562,12 +573,6 @@ class FullApplySite : public ApplySite {
|
562 | 573 | return op.getOperandNumber() < getOperandIndexOfFirstArgument();
|
563 | 574 | }
|
564 | 575 |
|
565 |
| - /// Returns true if \p op is an operand that passes an indirect |
566 |
| - /// result argument to the apply site. |
567 |
| - bool isIndirectResultOperand(const Operand &op) const { |
568 |
| - return getCalleeArgIndex(op) < getNumIndirectSILResults(); |
569 |
| - } |
570 |
| - |
571 | 576 | /// Is this an ApplySite that begins the evaluation of a coroutine.
|
572 | 577 | bool beginsCoroutineEvaluation() const {
|
573 | 578 | switch (getKind()) {
|
@@ -637,6 +642,12 @@ class FullApplySite : public ApplySite {
|
637 | 642 | llvm_unreachable("covered switch isn't covered");
|
638 | 643 | }
|
639 | 644 |
|
| 645 | + /// Returns true if \p op is an operand that passes an indirect |
| 646 | + /// result argument to the apply site. |
| 647 | + bool isIndirectResultOperand(const Operand &op) const { |
| 648 | + return getCalleeArgIndex(op) < getNumIndirectSILResults(); |
| 649 | + } |
| 650 | + |
640 | 651 | static FullApplySite getFromOpaqueValue(void *p) { return FullApplySite(p); }
|
641 | 652 |
|
642 | 653 | static bool classof(const SILInstruction *inst) {
|
@@ -729,4 +740,23 @@ template <> struct DenseMapInfo<::swift::FullApplySite> {
|
729 | 740 |
|
730 | 741 | } // namespace llvm
|
731 | 742 |
|
| 743 | +//===----------------------------------------------------------------------===// |
| 744 | +// Inline Definitions to work around Forward Declaration |
| 745 | +//===----------------------------------------------------------------------===// |
| 746 | + |
| 747 | +namespace swift { |
| 748 | + |
| 749 | +inline Optional<FullApplySite> ApplySite::asFullApplySite() const { |
| 750 | + return FullApplySite::isa(getInstruction()); |
| 751 | +} |
| 752 | + |
| 753 | +inline bool ApplySite::isIndirectResultOperand(const Operand &op) const { |
| 754 | + auto fas = asFullApplySite(); |
| 755 | + if (!fas) |
| 756 | + return false; |
| 757 | + return fas->isIndirectResultOperand(op); |
| 758 | +} |
| 759 | + |
| 760 | +} // namespace swift |
| 761 | + |
732 | 762 | #endif
|
0 commit comments