DWARF Standard


HOME
SPECIFICATIONS
FAQ
ISSUES



211206.2 Markus Metzger Stack piece operators Enhancement Open Markus Metzger


Section 2.6.12, pg 42

Arrays may be partially registerized such that the currently processed
elements are held in registers, whereas the remainder of the array remains
in memory.  Consider the loop in this C function, for example:

extern void foo(uint32_t dst[], uint32_t src[], int len) {
  for (int i = 0; i < len; ++i)
    dst[i] += src[i];
}

Inside the loop body, the machine code would load src[i] and dst[i] into
registers, add them, and store the result back into dst[i].

Considering the location of dst and src, the elements dst[i] and src[i]
would be located in registers, all other elements are located in memory.
Since the location depends on the dynamic value of i, the location of src
and dst cannot be described using the existing DW_OP_piece operators.

We propose four new operators
    DW_OP_piece_stack
    DW_OP_bit_piece_stack
    DW_OP_bit_piece_stack_offset
    DW_OP_piece_rest
that extend the existing family of piece operators by variants that take
some or all of their operands from the DWARF stack, thus allowing them to
be computed.  See below for detailed definitions.

Using the above new operators, we can now describe the location of dst in
three pieces.  Let R0 contain the base address of dst, R1 contain i, and
R2 contain dst[i].

  1. elements 0..i are located in memory
     DW_OP_breg0 0
     DW_OP_breg1 0
     DW_OP_lit4
     DW_OP_mul
     DW_OP_piece_stack

  2. element i is located in R2
     DW_OP_reg2
     DW_OP_piece 4

  3. elements i+1.. are located in memory
     DW_OP_breg0 0
     DW_OP_breg1 4
     DW_OP_lit4
     DW_OP_mul
     DW_OP_add
     DW_OP_piece_rest
 
Proposed Changes
================

Section 2.6.1.2, pg. 42.

Add
    3. DW_OP_piece_stack

       The DW_OP_piece_stack operation works similar to DW_OP_piece except that
       it takes its argument from the DWARF stack.

       The DW_OP_piece operation takes no operands.  It pops the topmost
       entry off the stack and interprets it as an unsigned integer,
       which describes the size in bytes of the piece of the object
       referenced by the preceding simple location description. If the
       piece is located in a register, but does not occupy the entire
       register, the placement of the piece within that register is
       defined by the ABI.

    4. DW_OP_bit_piece_stack
       The DW_OP_bit_piece_stack operation works similar to DW_OP_bit_piece
       except that it takes its arguments from the DWARF stack.

       The DW_OP_bit_piece_stack operation takes no operands.  It pops the
       topmost entry off the stack and interprets it as unsigned integer
       giving the size in bits of the piece.  It then pops the next entry
       off the stack and interprets it as unsigned integer giving the
       offset in bits from the location defined by the preceding DWARF
       location description

    5. DW_OP_bit_piece_stack_offset
       The DW_OP_bit_piece_stack_offset operation works similar to
       DW_OP_bit_piece except that it takes its offset argument from the
       DWARF stack.

       The DW_OP_bit_piece_stack_offset operation takes a single operand,
       which is an unsigned LEB128 number.  The number describes the size
       in bytes of the piece.  It pops the topmost entry off the stack and
       interprets it as unsigned integer giving the offset of the object
       referenced by the preceding DWARF location description.

    6. DW_OP_piece_rest
       The DW_OP_piece_rest operation takes no operands.  The preceding
       simple location description occupies the remainder of the object.
       non-normative: This operator can be used when the size of the
       object is not known.

 


All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2007-2021 by DWARF Standards Committee.