File: BitIdx.md

package info (click to toggle)
rust-bitvec 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,780 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,273 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Semantic Bit Index

This type is a counter in the ring `0 .. R::BITS` and serves to mark a semantic
index within some register element. It is a virtual index, and is the stored
value used in pointer encodings to track region start information.

It is translated to a real index through the [`BitOrder`] trait. This virtual
index is the only counter that can be used for address computation, and once
lowered to an electrical index through [`BitOrder::at`], the electrical address
can only be used for setting up machine instructions.

## Type Parameters

- `R`: The register element that this index governs.

## Validity

Values of this type are **required** to be in the range `0 .. R::BITS`. Any
value not less than [`R::BITS`] makes the program invalid, and will likely cause
either a crash or incorrect memory access.

## Construction

This type can never be constructed outside of the `bitvec` crate. It is passed
in to [`BitOrder`] implementations, which may use it to construct electrical
position values from it. All values of this type constructed by `bitvec` are
known to be correct in their region; no other construction site can be trusted.

[`BitOrder`]: crate::order::BitOrder
[`BitOrder::at`]: crate::order::BitOrder::at
[`R::BITS`]: funty::Integral::BITS