#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Flags(pub u8);
impl Flags {
pub const NONE: Flags = Flags(0);
pub const N: Flags = Flags(0b1000);
pub const Z: Flags = Flags(0b0100);
pub const C: Flags = Flags(0b0010);
pub const V: Flags = Flags(0b0001);
pub const NZCV: Flags = Flags(0b1111);
pub const fn contains(self, other: Flags) -> bool {
self.0 & other.0 == other.0
}
pub const fn is_empty(self) -> bool {
self.0 == 0
}
pub const fn for_condition(bits: u8) -> Flags {
match crate::condition::always_holds(bits) {
true => Flags::NONE,
false => Flags::NZCV,
}
}
}
impl core::ops::BitOr for Flags {
type Output = Flags;
fn bitor(self, other: Flags) -> Flags {
Flags(self.0 | other.0)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct FlagEffect {
pub writes: Flags,
pub reads: Flags,
pub float_compare: bool,
}
impl FlagEffect {
pub const NONE: FlagEffect = FlagEffect {
writes: Flags::NONE,
reads: Flags::NONE,
float_compare: false,
};
}