Issue 191025.1: DW_OP_bit_piece offset operand mostly does matter

Author: Paul T Robinson
Champion: Paul T Robinson
Date submitted: 2019-10-25
Date revised: 2021-04-19
Date closed: 2021-05-17
Type: Editorial
Status: Accepted
DWARF Version: 6
Section, pg 42
The description of DW_OP_bit_piece lists several cases for the preceding 
location description:
- empty (no location description)
- register
- implicit or stack value
- memory address

For the empty case, the spec explicitly says the bit offset operand 
"doesn't matter."  For implicit value or stack value, the piece must 
use the least significant bits; in these cases, the bit offset again 
doesn't matter, although the spec doesn't say so in so many words.

In fact, there is an argument that for the implicit value descriptions
(implicit value, stack value, implicit pointer), the offset operand
could be useful, as a substitute for an explicit shift operation.


(For clarity in discussing the changes, I've presented each sentence
individually, and indicated whether the proposal changes it.  I feel
that presenting the entire paragraph is helpful, but presenting it in
one lump made it hard to identify the proposed changes.)

Interpretation of the offset depends on the location description.

If the location description is empty, the DW_OP_bit_piece operation
describes a piece consisting of the given number of bits whose values
are undefined, and the offset is ignored.
(reworded, no semantic change)

(third sentence [register case] removed)

If the location is a memory address, the DW_OP_bit_piece operation
describes a sequence of bits relative to the location whose address is
on the top of the DWARF stack using the bit numbering and direction
conventions that are appropriate to the current language on the target

In all other cases, the source of the piece is either a register or an
implicit value description (section; the offset is from the
least significant bit of the register or implicit value.

2021-02-22 Revised.
2021-03-23 Revised.  Previous version:
2021-04-19 Revised.  Previous version:
2021-05-17 Accepted.