[llvm] [IR] Implementation and lowering of bitinsert and bitextract (PR #200605)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 25 04:02:19 PDT 2026
https://github.com/antoniofrighetto commented:
LangRef changes could use a little bit of more improvement. I think the introduction may be expanded at least, e.g.:
```
Instructions for bit-range manipulation on :ref:`byte type <t_byte>` values.
````
When documenting `bitextract`, I'm not sure `<tx>` is self-explanatory enough (possibly because, conventionally, the syntax precedes the overview). Maybe something like `<bty>` or `b<N>` to make sure we refer to a byte type? E.g.,:
`<result> = bitextract <ty>, <bty> <source>, i32 <offset> ; yields <ty>`
Following LangRef style, we usually cross-reference to type definitions and format operands when possible. Adding them to your version, and slightly adjusting the phrasing to LangRef's convention, the sections could read, e.g., as follows:
```
Overview:
"""""""""
The '``bitextract``' instruction reads a contiguous range of bits from a
:ref:`byte type <t_byte>` value and returns them as a value of type ``ty``.
Arguments:
""""""""""
``<ty>`` is any :ref:`single value type <t_single_value>` and specifies
the result type. The first operand, ``source``, must be a value of
:ref:`byte type <t_byte>`. The ``offset`` operand is an ``i32`` giving
the bit position at which the extraction begins within ``source``.
Semantics:
""""""""""
The result is the bit range ``source[offset : offset + bitwidth(ty))``,
reinterpreted as a value of type ``ty`` as if by a ``bitcast``.
Bit ``0`` is the least significant bit of ``source``.
If ``offset + bitwidth(ty)`` is greater than ``bitwidth(source)``,
:ref:`poison value <poisonvalues>` is returned.
```
(Analogously for bitinsert.)
Please make sure the section-underline lengths match the title ones (IIRC, it wouldn't render properly otherwise), e.g.:
```
'``bitextract``' Instruction
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
https://github.com/llvm/llvm-project/pull/200605
More information about the llvm-commits
mailing list