@@ -1936,6 +1936,7 @@ class ApplyInstBase<Impl, Base, true>
1936
1936
return OperandValueArrayRef (opsWithoutSelf);
1937
1937
}
1938
1938
1939
+ // / Return the SILArgumentConvention for the given applied argument index.
1939
1940
SILArgumentConvention getArgumentConvention (unsigned index) const {
1940
1941
return getSubstCalleeConv ().getSILArgumentConvention (index);
1941
1942
}
@@ -7620,47 +7621,59 @@ class ApplySite {
7620
7621
FOREACH_IMPL_RETURN (getSubstitutionMap ());
7621
7622
}
7622
7623
7623
- // / The arguments passed to this instruction.
7624
+ // / Return the associated specialization information.
7625
+ const GenericSpecializationInformation *getSpecializationInfo () const {
7626
+ FOREACH_IMPL_RETURN (getSpecializationInfo ());
7627
+ }
7628
+
7629
+ // / Return an operand list corresponding to the applied arguments.
7624
7630
MutableArrayRef<Operand> getArgumentOperands () const {
7625
7631
FOREACH_IMPL_RETURN (getArgumentOperands ());
7626
7632
}
7627
7633
7628
- // / The arguments passed to this instruction .
7634
+ // / Return a list of applied argument values .
7629
7635
OperandValueArrayRef getArguments () const {
7630
7636
FOREACH_IMPL_RETURN (getArguments ());
7631
7637
}
7632
7638
7633
- // / The number of call arguments.
7639
+ // / Return the number of applied arguments.
7634
7640
unsigned getNumArguments () const {
7635
7641
FOREACH_IMPL_RETURN (getNumArguments ());
7636
7642
}
7637
7643
7638
- unsigned getOperandIndexOfFirstArgument () {
7639
- FOREACH_IMPL_RETURN (getArgumentOperandNumber ());
7644
+ // / Return the apply operand for the given applied argument index.
7645
+ Operand &getArgumentRef (unsigned i) const { return getArgumentOperands ()[i]; }
7646
+
7647
+ // / Return the ith applied argument.
7648
+ SILValue getArgument (unsigned i) const { return getArguments ()[i]; }
7649
+
7650
+ // / Set the ith applied argument.
7651
+ void setArgument (unsigned i, SILValue V) const {
7652
+ getArgumentOperands ()[i].set (V);
7640
7653
}
7641
7654
7642
- // / Return the associated specialization information .
7643
- const GenericSpecializationInformation * getSpecializationInfo () const {
7644
- FOREACH_IMPL_RETURN (getSpecializationInfo ());
7655
+ // / Return the operand index of the first applied argument .
7656
+ unsigned getOperandIndexOfFirstArgument () const {
7657
+ FOREACH_IMPL_RETURN (getArgumentOperandNumber ());
7645
7658
}
7646
7659
#undef FOREACH_IMPL_RETURN
7647
7660
7648
- // / The arguments passed to this instruction, without self.
7649
- OperandValueArrayRef getArgumentsWithoutSelf () const {
7650
- switch (Inst-> getKind ()) {
7651
- case SILInstructionKind::ApplyInst:
7652
- return cast<ApplyInst>(Inst)-> getArgumentsWithoutSelf ();
7653
- case SILInstructionKind::BeginApplyInst:
7654
- return cast<BeginApplyInst>(Inst)-> getArgumentsWithoutSelf ();
7655
- case SILInstructionKind::TryApplyInst:
7656
- return cast<TryApplyInst>( Inst)-> getArgumentsWithoutSelf ( );
7657
- default :
7658
- llvm_unreachable ( " not implemented for this instruction! " );
7659
- }
7661
+ // / Returns true if \p oper is an argument operand and not the callee
7662
+ // / operand.
7663
+ bool isArgumentOperand ( const Operand &oper) const {
7664
+ return oper. getOperandNumber () >= getOperandIndexOfFirstArgument ();
7665
+ }
7666
+
7667
+ // / Return the applied argument index for the given operand.
7668
+ unsigned getArgumentIndex ( const Operand &oper) const {
7669
+ assert (oper. getUser () == Inst);
7670
+ assert ( isArgumentOperand (oper));
7671
+
7672
+ return oper. getOperandNumber () - getOperandIndexOfFirstArgument ();
7660
7673
}
7661
7674
7662
- // Get the callee argument index corresponding to the caller's first applied
7663
- // argument. Returns 0 for full applies. May return > 0 for partial applies.
7675
+ // / Return the callee's function argument index corresponding to the first
7676
+ // / applied argument: 0 for full applies; >= 0 for partial applies.
7664
7677
unsigned getCalleeArgIndexOfFirstAppliedArg () const {
7665
7678
switch (Inst->getKind ()) {
7666
7679
case SILInstructionKind::ApplyInst:
@@ -7683,35 +7696,30 @@ class ApplySite {
7683
7696
}
7684
7697
}
7685
7698
7686
- // / Returns true if \p oper is an argument operand and not the callee
7687
- // / operand.
7688
- bool isArgumentOperand (const Operand &oper) {
7689
- return oper.getOperandNumber () >= getOperandIndexOfFirstArgument ();
7699
+ // / Return the callee's function argument index corresponding to the given
7700
+ // / apply operand. Each function argument index identifies a
7701
+ // / SILFunctionArgument in the callee and can be used as a
7702
+ // / SILFunctionConvention argument index.
7703
+ // /
7704
+ // / Note: Passing an applied argument index into SILFunctionConvention, as
7705
+ // / opposed to a function argument index, is incorrect.
7706
+ unsigned getCalleeArgIndex (const Operand &oper) const {
7707
+ return getCalleeArgIndexOfFirstAppliedArg () + getArgumentIndex (oper);
7690
7708
}
7691
7709
7692
- // Translate the index of the argument to the full apply or partial_apply into
7693
- // to the corresponding index into the arguments of the called function.
7694
- unsigned getCalleeArgIndex (const Operand &oper) {
7695
- assert (oper.getUser () == Inst);
7696
- assert (isArgumentOperand (oper));
7697
-
7698
- unsigned appliedArgIdx =
7699
- oper.getOperandNumber () - getOperandIndexOfFirstArgument ();
7700
-
7701
- return getCalleeArgIndexOfFirstAppliedArg () + appliedArgIdx;
7710
+ // / Return the SILArgumentConvention for the given applied argument operand.
7711
+ SILArgumentConvention getArgumentConvention (Operand &oper) const {
7712
+ unsigned calleeArgIdx =
7713
+ getCalleeArgIndexOfFirstAppliedArg () + getArgumentIndex (oper);
7714
+ return getSubstCalleeConv ().getSILArgumentConvention (calleeArgIdx);
7702
7715
}
7703
7716
7704
- Operand &getArgumentRef (unsigned i) const { return getArgumentOperands ()[i]; }
7705
-
7706
- // / Return the ith argument passed to this instruction.
7707
- SILValue getArgument (unsigned i) const { return getArguments ()[i]; }
7708
-
7709
- // / Set the ith argument of this instruction.
7710
- void setArgument (unsigned i, SILValue V) const {
7711
- getArgumentOperands ()[i].set (V);
7717
+ // FIXME: This is incorrect. It will be removed in the next commit.
7718
+ SILArgumentConvention getArgumentConvention (unsigned index) const {
7719
+ return getSubstCalleeConv ().getSILArgumentConvention (index);
7712
7720
}
7713
7721
7714
- // / Return the self argument passed to this instruction .
7722
+ // / Return true if ' self' is an applied argument .
7715
7723
bool hasSelfArgument () const {
7716
7724
switch (Inst->getKind ()) {
7717
7725
case SILInstructionKind::ApplyInst:
@@ -7725,7 +7733,7 @@ class ApplySite {
7725
7733
}
7726
7734
}
7727
7735
7728
- // / Return the self argument passed to this instruction .
7736
+ // / Return the applied ' self' argument value .
7729
7737
SILValue getSelfArgument () const {
7730
7738
switch (Inst->getKind ()) {
7731
7739
case SILInstructionKind::ApplyInst:
@@ -7739,7 +7747,7 @@ class ApplySite {
7739
7747
}
7740
7748
}
7741
7749
7742
- // / Return the self operand passed to this instruction .
7750
+ // / Return the ' self' apply operand .
7743
7751
Operand &getSelfArgumentOperand () {
7744
7752
switch (Inst->getKind ()) {
7745
7753
case SILInstructionKind::ApplyInst:
@@ -7753,8 +7761,18 @@ class ApplySite {
7753
7761
}
7754
7762
}
7755
7763
7756
- SILArgumentConvention getArgumentConvention (unsigned index) const {
7757
- return getSubstCalleeConv ().getSILArgumentConvention (index);
7764
+ // / Return a list of applied arguments without self.
7765
+ OperandValueArrayRef getArgumentsWithoutSelf () const {
7766
+ switch (Inst->getKind ()) {
7767
+ case SILInstructionKind::ApplyInst:
7768
+ return cast<ApplyInst>(Inst)->getArgumentsWithoutSelf ();
7769
+ case SILInstructionKind::BeginApplyInst:
7770
+ return cast<BeginApplyInst>(Inst)->getArgumentsWithoutSelf ();
7771
+ case SILInstructionKind::TryApplyInst:
7772
+ return cast<TryApplyInst>(Inst)->getArgumentsWithoutSelf ();
7773
+ default :
7774
+ llvm_unreachable (" not implemented for this instruction!" );
7775
+ }
7758
7776
}
7759
7777
7760
7778
static ApplySite getFromOpaqueValue (void *p) {
0 commit comments