Skip to content

Commit ad584a7

Browse files
committed
[sil] Add getOperand() variants for pack instructions.
We already had getValue() variants... this just expands those to operands. The reason why this is useful is that these instructions have specific operands with specific meanings as assigned by an internal enum struct. Rather than having to access those directly by using getAllOperand()[EnumCase]... better to have a named method.
1 parent 3ffe5c5 commit ad584a7

File tree

1 file changed

+55
-16
lines changed

1 file changed

+55
-16
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7983,12 +7983,20 @@ class PackElementGetInst final
79837983
SILType elementType);
79847984

79857985
public:
7986-
SILValue getIndex() const {
7987-
return getAllOperands()[IndexOperand].get();
7986+
SILValue getIndex() const { return getIndexOperand()->get(); }
7987+
7988+
Operand *getIndexOperand() { return &getAllOperands()[IndexOperand]; }
7989+
7990+
const Operand *getIndexOperand() const {
7991+
return &getAllOperands()[IndexOperand];
79887992
}
79897993

7990-
SILValue getPack() const {
7991-
return getAllOperands()[PackOperand].get();
7994+
SILValue getPack() const { return getPackOperand()->get(); }
7995+
7996+
Operand *getPackOperand() { return &getAllOperands()[PackOperand]; }
7997+
7998+
const Operand *getPackOperand() const {
7999+
return &getAllOperands()[PackOperand];
79928000
}
79938001

79948002
CanSILPackType getPackType() const {
@@ -8028,18 +8036,29 @@ class PackElementSetInst
80288036
ArrayRef<Operand> getAllOperands() const { return Operands.asArray(); }
80298037
MutableArrayRef<Operand> getAllOperands() { return Operands.asArray(); }
80308038

8031-
SILValue getValue() const {
8032-
return getAllOperands()[ValueOperand].get();
8039+
SILValue getValue() const { return getValueOperand()->get(); }
8040+
8041+
const Operand *getValueOperand() const {
8042+
return &getAllOperands()[ValueOperand];
80338043
}
80348044

8035-
SILValue getIndex() const {
8036-
return getAllOperands()[IndexOperand].get();
8045+
Operand *getValueOperand() { return &getAllOperands()[ValueOperand]; }
8046+
8047+
SILValue getIndex() const { return getIndexOperand()->get(); }
8048+
8049+
const Operand *getIndexOperand() const {
8050+
return &getAllOperands()[IndexOperand];
80378051
}
8052+
Operand *getIndexOperand() { return &getAllOperands()[IndexOperand]; }
8053+
8054+
SILValue getPack() const { return getPackOperand()->get(); }
80388055

8039-
SILValue getPack() const {
8040-
return getAllOperands()[PackOperand].get();
8056+
const Operand *getPackOperand() const {
8057+
return &getAllOperands()[PackOperand];
80418058
}
80428059

8060+
Operand *getPackOperand() { return &getAllOperands()[PackOperand]; }
8061+
80438062
CanSILPackType getPackType() const {
80448063
return getPack()->getType().castTo<SILPackType>();
80458064
}
@@ -8079,12 +8098,20 @@ class TuplePackElementAddrInst final
80798098
SILType elementType);
80808099

80818100
public:
8082-
SILValue getIndex() const {
8083-
return getAllOperands()[IndexOperand].get();
8101+
SILValue getIndex() const { return getIndexOperand()->get(); }
8102+
8103+
Operand *getIndexOperand() { return &getAllOperands()[IndexOperand]; }
8104+
8105+
const Operand *getIndexOperand() const {
8106+
return &getAllOperands()[IndexOperand];
80848107
}
80858108

8086-
SILValue getTuple() const {
8087-
return getAllOperands()[TupleOperand].get();
8109+
SILValue getTuple() const { return getTupleOperand()->get(); }
8110+
8111+
Operand *getTupleOperand() { return &getAllOperands()[TupleOperand]; }
8112+
8113+
const Operand *getTupleOperand() const {
8114+
return &getAllOperands()[TupleOperand];
80888115
}
80898116

80908117
CanTupleType getTupleType() const {
@@ -8124,9 +8151,21 @@ class TuplePackExtractInst final
81248151
ValueOwnershipKind forwardingOwnershipKind);
81258152

81268153
public:
8127-
SILValue getIndex() const { return getAllOperands()[IndexOperand].get(); }
8154+
SILValue getIndex() const { return getIndexOperand()->get(); }
81288155

8129-
SILValue getTuple() const { return getAllOperands()[TupleOperand].get(); }
8156+
Operand *getIndexOperand() { return &getAllOperands()[IndexOperand]; }
8157+
8158+
const Operand *getIndexOperand() const {
8159+
return &getAllOperands()[IndexOperand];
8160+
}
8161+
8162+
SILValue getTuple() const { return getTupleOperand()->get(); }
8163+
8164+
Operand *getTupleOperand() { return &getAllOperands()[TupleOperand]; }
8165+
8166+
const Operand *getTupleOperand() const {
8167+
return &getAllOperands()[TupleOperand];
8168+
}
81308169

81318170
CanTupleType getTupleType() const {
81328171
return getTuple()->getType().castTo<TupleType>();

0 commit comments

Comments
 (0)