@@ -567,19 +567,30 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
567567 bool maySuspend () const ;
568568
569569private:
570- // / Predicate used to filter OperandValueRange.
570+ // / Functor for Operand::get()
571571 struct OperandToValue ;
572- // / Predicate used to filter TransformedOperandValueRange.
572+ // / Functor for Operand::get()
573+ struct OperandRefToValue ;
574+ // / Predicate to filter NonTypeDependentOperandValueRange
575+ struct NonTypeDependentOperandToValue ;
576+ // / Predicate to filter TransformedOperandValueRange.
573577 struct OperandToTransformedValue ;
574578
575579public:
576- using OperandValueRange =
577- OptionalTransformRange<ArrayRef<Operand>, OperandToValue>;
580+ using OperandValueRange = TransformRange<ArrayRef<Operand*>, OperandToValue>;
581+ using OperandRefValueRange =
582+ TransformRange<ArrayRef<Operand>, OperandRefToValue>;
583+ using NonTypeDependentOperandValueRange =
584+ OptionalTransformRange<ArrayRef<Operand>, NonTypeDependentOperandToValue>;
578585 using TransformedOperandValueRange =
579- OptionalTransformRange<ArrayRef<Operand>, OperandToTransformedValue>;
586+ OptionalTransformRange<ArrayRef<Operand>, OperandToTransformedValue>;
587+
588+ static OperandValueRange getOperandValues (ArrayRef<Operand*> operands);
589+
590+ OperandRefValueRange getOperandValues () const ;
591+
592+ NonTypeDependentOperandValueRange getNonTypeDependentOperandValues () const ;
580593
581- OperandValueRange
582- getOperandValues (bool skipTypeDependentOperands = false ) const ;
583594 TransformedOperandValueRange
584595 getOperandValues (std::function<SILValue(SILValue)> transformFn,
585596 bool skipTypeDependentOperands) const ;
@@ -762,7 +773,7 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
762773
763774 // / Verify that all operands of this instruction have compatible ownership
764775 // / with this instruction.
765- void verifyOperandOwnership () const ;
776+ void verifyOperandOwnership (SILModuleConventions *silConv = nullptr ) const ;
766777
767778 // / Verify that this instruction and its associated debug information follow
768779 // / all SIL debug info invariants.
@@ -879,14 +890,24 @@ inline const SILNode *SILNode::instAsNode(const SILInstruction *inst) {
879890
880891
881892struct SILInstruction ::OperandToValue {
893+ SILValue operator ()(const Operand *use) const {
894+ return use->get ();
895+ }
896+ };
897+
898+ struct SILInstruction ::OperandRefToValue {
899+ SILValue operator ()(const Operand &use) const {
900+ return use.get ();
901+ }
902+ };
903+
904+ struct SILInstruction ::NonTypeDependentOperandToValue {
882905 const SILInstruction &i;
883- bool skipTypeDependentOps;
884906
885- OperandToValue (const SILInstruction &i, bool skipTypeDependentOps)
886- : i(i), skipTypeDependentOps(skipTypeDependentOps) {}
907+ NonTypeDependentOperandToValue (const SILInstruction &i): i(i) {}
887908
888909 Optional<SILValue> operator ()(const Operand &use) const {
889- if (skipTypeDependentOps && i.isTypeDependentOperand (use))
910+ if (i.isTypeDependentOperand (use))
890911 return None;
891912 return use.get ();
892913 }
@@ -910,11 +931,21 @@ struct SILInstruction::OperandToTransformedValue {
910931 }
911932};
912933
934+ inline SILInstruction::OperandValueRange
935+ SILInstruction::getOperandValues (ArrayRef<Operand*> operands) {
936+ return OperandValueRange (operands, OperandToValue ());
937+ }
938+
913939inline auto
914- SILInstruction::getOperandValues (bool skipTypeDependentOperands) const
915- -> OperandValueRange {
916- return OperandValueRange (getAllOperands (),
917- OperandToValue (*this , skipTypeDependentOperands));
940+ SILInstruction::getOperandValues () const -> OperandRefValueRange {
941+ return OperandRefValueRange (getAllOperands (), OperandRefToValue ());
942+ }
943+
944+ inline auto
945+ SILInstruction::getNonTypeDependentOperandValues () const
946+ -> NonTypeDependentOperandValueRange {
947+ return NonTypeDependentOperandValueRange (getAllOperands (),
948+ NonTypeDependentOperandToValue (*this ));
918949}
919950
920951inline auto
@@ -1145,6 +1176,18 @@ class OwnershipForwardingMixin {
11451176 return isa (i);
11461177 return false ;
11471178 }
1179+
1180+ // / Return true if the forwarded value has the same representation. If true,
1181+ // / then the result can be mapped to the same storage without a move or copy.
1182+ // /
1183+ // / \p inst is an OwnershipForwardingMixin
1184+ static bool hasSameRepresentation (SILInstruction *inst);
1185+
1186+ // / Return true if the forwarded value is address-only either before or after
1187+ // / forwarding.
1188+ // /
1189+ // / \p inst is an OwnershipForwardingMixin
1190+ static bool isAddressOnly (SILInstruction *inst);
11481191};
11491192
11501193// / A single value inst that forwards a static ownership from its first operand.
0 commit comments