@@ -7654,6 +7654,99 @@ class OpenPackElementInst final
76547654 }
76557655};
76567656
7657+ // / Get the value previously stored in a pack by pack_element_set.
7658+ class PackElementGetInst final
7659+ : public InstructionBaseWithTrailingOperands<
7660+ SILInstructionKind::PackElementGetInst,
7661+ PackElementGetInst, SingleValueInstruction> {
7662+ public:
7663+ enum {
7664+ IndexOperand = 0 ,
7665+ PackOperand = 1
7666+ };
7667+
7668+ private:
7669+ friend SILBuilder;
7670+
7671+ PackElementGetInst (SILDebugLocation debugLoc,
7672+ ArrayRef<SILValue> allOperands,
7673+ SILType elementType)
7674+ : InstructionBaseWithTrailingOperands(allOperands, debugLoc,
7675+ elementType) {}
7676+
7677+ static PackElementGetInst *create (SILFunction &F,
7678+ SILDebugLocation debugLoc,
7679+ SILValue indexOperand,
7680+ SILValue packOperand,
7681+ SILType elementType);
7682+
7683+ public:
7684+ SILValue getIndex () const {
7685+ return getAllOperands ()[IndexOperand].get ();
7686+ }
7687+
7688+ SILValue getPack () const {
7689+ return getAllOperands ()[PackOperand].get ();
7690+ }
7691+
7692+ CanSILPackType getPackType () const {
7693+ return getPack ()->getType ().castTo <SILPackType>();
7694+ }
7695+
7696+ SILType getElementType () const {
7697+ return getType ();
7698+ }
7699+ };
7700+
7701+ // / Set the value stored in a pack.
7702+ class PackElementSetInst
7703+ : public InstructionBase<SILInstructionKind::PackElementSetInst,
7704+ NonValueInstruction> {
7705+ public:
7706+ enum {
7707+ ValueOperand = 0 ,
7708+ IndexOperand = 1 ,
7709+ PackOperand = 2
7710+ };
7711+
7712+ private:
7713+ friend SILBuilder;
7714+
7715+ FixedOperandList<3 > Operands;
7716+
7717+ PackElementSetInst (SILDebugLocation debugLoc,
7718+ SILValue valueOperand, SILValue indexOperand,
7719+ SILValue packOperand)
7720+ : InstructionBase(debugLoc),
7721+ Operands (this , valueOperand, indexOperand, packOperand) {
7722+ assert (packOperand->getType ().is <SILPackType>());
7723+ }
7724+
7725+ public:
7726+ ArrayRef<Operand> getAllOperands () const { return Operands.asArray (); }
7727+ MutableArrayRef<Operand> getAllOperands () { return Operands.asArray (); }
7728+
7729+ SILValue getValue () const {
7730+ return getAllOperands ()[ValueOperand].get ();
7731+ }
7732+
7733+ SILValue getIndex () const {
7734+ return getAllOperands ()[IndexOperand].get ();
7735+ }
7736+
7737+ SILValue getPack () const {
7738+ return getAllOperands ()[PackOperand].get ();
7739+ }
7740+
7741+ CanSILPackType getPackType () const {
7742+ return getPack ()->getType ().castTo <SILPackType>();
7743+ }
7744+
7745+ SILType getElementType () const {
7746+ return getValue ()->getType ();
7747+ }
7748+ };
7749+
76577750// / Projects the capture storage address from a @block_storage address.
76587751class ProjectBlockStorageInst
76597752 : public UnaryInstructionBase<SILInstructionKind::ProjectBlockStorageInst,
0 commit comments