Skip to content

Commit 904b1a9

Browse files
committed
[SIL.rst] Add textual examples for some of the pack instructions.
Just writing some tests for the pack instructions and I would have found having a textual SIL example in SIL.rst of how to write them to be useful. Just paying it forward.
1 parent afb042d commit 904b1a9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/SIL.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7454,6 +7454,8 @@ scalar_pack_index
74547454

74557455
sil-instruction ::= 'scalar_pack_index' int-literal 'of' sil-type
74567456

7457+
%index = scalar_pack_index 0 of $Pack{Int, repeat each T, Int}
7458+
74577459
Produce the dynamic pack index of a scalar (non-pack-expansion)
74587460
component of a pack. The type operand is the indexed pack type. The
74597461
integer operand is an index into the components of this pack type; it
@@ -7573,6 +7575,8 @@ pack_element_get
75737575

75747576
sil-instruction ::= 'pack_element_get' sil-value 'of' sil-operand 'as' sil-type
75757577

7578+
%addr = pack_element_get %index of %pack : $*Pack{Int, repeat each T} as $*Int
7579+
75767580
Extracts the value previously stored in a pack at a particular index.
75777581
If the pack element is uninitialized, this has undefined behavior.
75787582

@@ -7591,6 +7595,8 @@ pack_element_set
75917595

75927596
sil-instruction ::= 'pack_element_set' sil-operand 'into' sil-value 'of' sil-operand
75937597

7598+
pack_element_set %addr : $*@pack_element("...") each U into %index of %pack : $*Pack{Int, repeat each T}
7599+
75947600
Places a value in a pack at a particular index.
75957601

75967602
Ownership is unclear for direct packs.

0 commit comments

Comments
 (0)