Skip to main content

is_bit

Function is_bit 

Source
pub fn is_bit(ty: Type) -> bool
Expand description

Whether a type is the one bit a truth value comes in.

One bit is a width the rule set is written at and is not one of slot’s four, because it is not a width the machine computes in. There is no one bit register and no one bit instruction: a value of this width lives in a whole byte with the other seven bits zero, which is what a setcc leaves behind, and every rule written at one bit is a byte instruction chosen because it keeps that true. The model says the same thing from the other side, giving setcc a meaning one bit wide, so the abstraction is stated in both places rather than assumed in either.

What makes the invariant hold rather than merely be usual is the short list of places a value of this width can come from. A comparison produces a zero or a one, a constant at this width is written as one, the three bitwise operations carry those through unchanged, and everything else at one bit reaches slot and gets nothing. A load is the one that reaches outside the compiler, since it gives back whatever byte was at the address, and what says that byte is a zero or a one is C rather than the machine: the value of a _Bool object holding anything else is undefined. The store at this width is what keeps that true from the other side, because the only values it can be handed are the ones this paragraph lists.