rocq/backend/FrameSlots.v
Stack slots for temporaries (frame_slots.pl's temp_slots/7, with shared pools): each temporary gets a slot of its pool, and two whose live intervals are strictly disjoint may share one.
A temporary's interval is closed. It covers every write, even of a dead result, every use by an instruction, and every block boundary where the temporary is live in or out. One instruction is one point, with all its helper calls, so a result never overwrites its operands. The slots are found first-fit over the intervals in the standard order of range(Start, End, Pool, N), which makes the layout the Prolog compiler's, slot for slot.
Touches
A group of temporaries touched at one point: an instruction's uses or definitions, a block's phis, or the temporaries live into or out of a block.
| | | TouchPlain | ns : listname | |
| | | TouchLiveIn | ns : names | live(in, Ns) |
| | | TouchLiveOut | ns : names | live(out, Ns) |
As inst_ranges/5: the touches of the instructions is from the point p, each instruction's uses and definitions at its own point, in front of acc, the last first. With them, the point after the last instruction.
As block_ranges/8: the touches of the blocks bs from the point p, in front of acc, the last first, and the point after the last block. A block's live-in set and phis are at its own point, the jump's uses and the live-out set at its exit. The live sets keep only what can move a bound: the live-in set less prev_out, the live-out set of the block before, and the live-out set less the next block's live-in set.
As first_touches/3: each temporary mapped to the point of its first touch in ts. The live-in groups are left out if skip_in, else the live-out ones: a live-out set never moves a first touch, nor a live-in set a last one.
Ranges
As range(Start, End, Pool, N): the temporary n, of the pool, is live from the point start to the point stop, both included.
As class_pool/3 with shared pools: the pool a temporary of the class k is kept in. A proof has none.
The place of a pool's atom in the standard order: pointer, scalar, wide.
The standard order of two range(Start, End, Pool, N) terms.
The name of a variadic function's hidden parameter, the promoted argument packet: hidden(va_snapshot).
As temp_ranges/7: the live range of each of temps, the temporaries of a function with the parameters ps and the blocks bs, in the standard order. The parameters are touched at point 0 and the blocks start at 1. The hidden va_snapshot parameter is read by every va_args, so it is kept to the end.
Slots
As reuse_slot/7: the slot for a range from s to e among slots, each a slot's index and the end of the last range in it, of which there are n0. It is the first whose last range ends before s, or a new one. The result is the slots now, their number, and the index taken.
The slots of a function's temporaries: the slot of each, by name, in the order of the names, and the number of slots of each pool.
| sl_aliases | ||
| sl_scalars | : Z | |
| sl_pointers | : Z | |
| sl_wides | : Z |
A pool while its ranges are allocated: its slots and their number.
As allocate/6 and wide_slot/3: the ranges rs, in order, each given a slot of its pool.
As temp_slots/7: the slots of temps, the temporaries of a function with the parameters ps and the fused blocks bs.